Backfill cache-tags metadata onto existing S3 objects#14076
Merged
Conversation
e1dfaee to
0640c9c
Compare
This comment has been minimized.
This comment has been minimized.
Adds a dedicated table recording which crates have had their S3 objects backfilled with `cache-tags` metadata. Cache-tags state lives only in S3 metadata, not the database, so this table is what lets us prove full coverage before removing the delete-time URL fan-out. A row exists only for crates whose backfill completed. `crate_id` references `crates(id)` with `ON DELETE SET NULL` so a crate deleted mid-backfill nulls the reference instead of cascading the row away, while `crate_name` is retained so the record survives the deletion. The unique index on `crate_id` backs the backfill selection and lets the completion stamp upsert idempotently.
Adds a per-crate job that copies every S3 object for the crate over itself with `MetadataDirective=Replace`, re-supplying the `content-type` and `cache-control` attributes alongside the new `cache-tags` metadata. On success it adds the crate to the `cache_tags_backfills` table. The copy goes through `aws-sdk-s3` directly rather than the `Storage` abstraction, since `object_store` cannot express a metadata-replacing copy. This is temporary scaffolding and should be removed once the backfill is complete.
This adds a `backfill-cache-tags` subcommand that queues a `BackfillCacheTags` job per crate. `--backfill` selects every crate without a completed `cache_tags_backfills` row. Passing crate names instead queues just those. This is temporary scaffolding and should be removed once the backfill is complete.
0640c9c to
f1b7d04
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introducs temporary scaffolding to attach
cache-tagsmetadata to the S3 objects that predate #14075. CloudFront cannot synthesize a cache tag at the edge, so unfortunately, every pre-existing object has to be re-copied to attach the metadata.The PR introduces:
cache_tags_backfillstracking table, recording which crates have been backfilled.BackfillCacheTagsjob that copies every object for the crate over itself withMetadataDirective=Replaceand the newcache-tagsmetadata. The copy goes throughaws-sdk-s3directly, sinceobject_storecannot express a metadata-replacing copy.backfill-cache-tagsadmin command that queues those jobs.This can be removed again once the backfill is complete.
Note
The PR currently stacks on #14075 and includes its commits for now, until that one is merged.
Related