Skip to content

Backfill cache-tags metadata onto existing S3 objects#14076

Merged
Turbo87 merged 3 commits into
rust-lang:mainfrom
Turbo87:cache-tags-backfill
Jun 28, 2026
Merged

Backfill cache-tags metadata onto existing S3 objects#14076
Turbo87 merged 3 commits into
rust-lang:mainfrom
Turbo87:cache-tags-backfill

Conversation

@Turbo87

@Turbo87 Turbo87 commented Jun 26, 2026

Copy link
Copy Markdown
Member

This PR introducs temporary scaffolding to attach cache-tags metadata 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:

  • A cache_tags_backfills tracking table, recording which crates have been backfilled.
  • A per-crate BackfillCacheTags job that copies every object for the crate over itself with MetadataDirective=Replace and the new cache-tags metadata. The copy goes through aws-sdk-s3 directly, since object_store cannot express a metadata-replacing copy.
  • A backfill-cache-tags admin 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

@Turbo87 Turbo87 requested a review from a team June 26, 2026 13:34
@Turbo87 Turbo87 added the C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear label Jun 26, 2026
@Turbo87 Turbo87 force-pushed the cache-tags-backfill branch 2 times, most recently from e1dfaee to 0640c9c Compare June 27, 2026 19:51
@rustbot

This comment has been minimized.

Turbo87 added 3 commits June 28, 2026 10:54
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.
@Turbo87 Turbo87 force-pushed the cache-tags-backfill branch from 0640c9c to f1b7d04 Compare June 28, 2026 08:54
@Turbo87 Turbo87 marked this pull request as ready for review June 28, 2026 08:55
@Turbo87 Turbo87 merged commit 762e2dd into rust-lang:main Jun 28, 2026
12 checks passed
@Turbo87 Turbo87 deleted the cache-tags-backfill branch June 28, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants