Skip to content

The object sweep checks for unknown migrations only at the start of a run, so a migration during the run can make it delete live objects #535

Closed as not planned

Description

@pdevito3

Summary

The SweepObjects job checks for unknown migrations only one time, at the start of a run. A migration that a newer Server applies while an old Server's run is in progress is not seen. If that migration moves storage keys into a table that the old Server does not know, the old run deletes live objects.

Where

Main at 3b7a3c7122b9a3dd4a18c66c85640be95913ce4a.

Reproduction steps

  1. Start a sweep run on a Server built at commit A, with a bucket that has many pages.
  2. While the run lists its pages, apply a migration from commit B that moves the rows of an attachment table into a new table that commit A does not know. A test can do this with a fake ObjectStorage whose ListPageAsync applies the migration (or moves the rows with SQL) before it returns page 2.
  3. Let the run finish.

Expected

The run sees the new migration before it decides on the next page, and stops, as it does when the migration was applied before the run.

Actual

The run uses the old model for every page. The moved rows are not visible to it, so it deletes the objects of those rows that are older than the grace.

Impact

Data loss during a rolling deploy. The window needs a migration that moves storage keys into a new table while a run of the old Server is in progress, so it is rare. The loss is silent and cannot be undone.

Source

Finding L2 in the review comment of #526: #526 (comment)

Suggested fix

From the review: a check for each page makes the window smaller, but does not close it. A sound fix needs a lock that the migration also takes, for example a Postgres advisory lock that the sweep holds for its run and that the migration step takes before it applies.

Activity

  1. pdevito3 commented on Nov 21, 2026

    @pdevito3
    OwnerAuthor

    Closing as not worth the machinery. The bad case needs a migration that moves storage keys into a new table while an old Server's sweep run is in progress. A check before each page only narrows the window; the sound fix is an advisory lock that the migration step also takes, which is new deploy-time machinery for a rare case. Workaround if it ever matters: pause the sweep schedule during a deploy that moves storage key columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions