Skip to content

fix(ci): Discard partial worker databases before the bootstrap fallback - #131652

Merged
joshuarli merged 1 commit into
masterfrom
ci/bootstrap-snuba-restore-fallback
Nov 18, 2026
Merged

joshuarli merged 1 commit into
masterfrom
ci/bootstrap-snuba-restore-fallback

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #131172, fixing this Bugbot finding.

bootstrap-snuba.py bootstraps default_gw0, then copies it to the other worker databases with RESTORE. When a copy failed, the fallback bootstrapped on top of whatever was left over:

  • A RESTORE that fails partway leaves a half-created default_gwN. Its partial migrations_local can make snuba bootstrap skip migrations, so the tests would run against a broken schema.
  • A client timeout is an OSError, so it started the fallback while ClickHouse could still be running the RESTORE on the server. Over HTTP, ClickHouse doesn't cancel a non-readonly query when the client disconnects.

Each RESTORE now gets a known query ID. The fallback first kills any of those queries that are still running and waits for them to stop. Then it drops every target database, and only then bootstraps them. ClickHouse documents KILL QUERY as the way to cancel a restore. If the kill or a drop fails, phase 1 fails instead of bootstrapping on top of a partial database.

The copy-or-fallback logic moves out of main() into copy_or_bootstrap() so it can be unit tested. The happy path doesn't change.

via @joshuarli.

--

View Session [Sentry]

If copying default_gw0 to the other worker databases fails partway, the
fallback ran snuba bootstrap on a half-restored database, whose partial
migrations_local can make it skip migrations. A client timeout also left
the RESTORE running on the server while the fallback started.

Tag each RESTORE with a query_id, and in the fallback kill any that are
still running, then drop every target database before bootstrapping it.

Follow-up to #131172.

Co-Authored-By: Joshua Li <[email protected]>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 18, 2026
@joshuarli
joshuarli marked this pull request as ready for review November 18, 2026 18:55
@joshuarli
joshuarli requested a review from a team as a code owner November 18, 2026 18:55
@sentry-junior
sentry-junior Bot requested a review from joshuarli November 18, 2026 18:55
@joshuarli
joshuarli merged commit 4e94167 into master Nov 18, 2026
77 checks passed
@joshuarli
joshuarli deleted the ci/bootstrap-snuba-restore-fallback branch November 18, 2026 19:06
@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown

DI-2852

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

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant