fix(migrations): catch CommandError-wrapped ResolutionError in rolling-deployment skip - #2117
Merged
nicoloboschi merged 1 commit intoJun 11, 2026
Conversation
…g-deployment skip command.upgrade() never raises ResolutionError directly — alembic's ScriptDirectory._catch_revision_errors wraps it in CommandError, so the newer-bank rolling-deployment handler never fired and startup died with a raw traceback. Catch the wrapped form (cause-checked) and route it to the same warn-and-skip path; unrelated CommandErrors still propagate. Fixes vectorize-io#2114
nicoloboschi
approved these changes
Jun 11, 2026
nicoloboschi
left a comment
Collaborator
There was a problem hiding this comment.
Verified against installed alembic 1.17.1: _catch_revision_errors raises CommandError(...) from re, so __cause__ is genuinely the ResolutionError on the real command.upgrade → _upgrade_revs path. Cause-check is correct, unrelated CommandErrors still propagate, and the new no-DB tests faithfully mirror alembic's wrapping. Minimal and well-scoped.
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.
What
The rolling-deployment "newer bank" guard in
_run_migrations_internalcatchesResolutionError, butcommand.upgrade()never raises that directly — alembic'sScriptDirectory._catch_revision_errorswraps it inalembic.util.exc.CommandError. So when an older replica starts against a database migrated by newer code, the designed warn-and-skip path never fires and startup dies with a raw traceback.This PR catches the wrapped form too, cause-checked:
CommandErroris only swallowed whenisinstance(e.__cause__, ResolutionError); any otherCommandErrorpropagates unchanged.Fixes #2114
How it was hit
0.6.1 daemon starting against a bank migrated by 0.7.2 (head
c1d2e3f4a5b6) — full traceback in #2114. The handler's log message ("Skipping migrations") never appeared; instead the daemon refused to start.Tests
New
tests/test_migrations_newer_revision.py(modeled ontest_migrations_thread_safety.py— monkeypatchedcommand.upgrade, no DB needed):CommandError(cause=ResolutionError)→ warn-and-skip (the regression)ResolutionError→ warn-and-skip (existing behavior preserved)CommandError→ still raisesVerification
uv run pytest tests/test_migrations_newer_revision.py tests/test_migrations_thread_safety.py→ 4 passedruff check/ruff format --checkclean on both touched files