cutover: support multiple sources with rollback on partial failure#692
Merged
Conversation
bc13054 to
b2c1f54
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the move cutover flow to support N source databases by introducing per-source cutover configuration and adding a best-effort rollback when a multi-source rename partially fails.
Changes:
- Introduce
CutOverSourceand updateCutOver/NewCutOverto operate on[]CutOverSource. - Update cutover algorithm to lock/flush/verify/rename across all sources, with rollback of completed renames on partial failure.
- Update the move runner to wrap the existing single-source setup into a one-element
[]CutOverSource, and add multi-source cutover tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/move/runner.go | Adapts runner cutover construction to the new NewCutOver([]CutOverSource, ...) API. |
| pkg/move/cutover.go | Implements multi-source locking/flush verification and sequential rename with rollback on partial failure. |
| pkg/move/cutover_test.go | Adds tests for NewCutOver validation and a 2-source “happy path” integration test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1ecb141 to
c1f7871
Compare
Refactor CutOver to accept []CutOverSource instead of a single
db/feed pair. This prepares the cutover for N:M move operations
where multiple source databases need to be locked, flushed, and
renamed atomically.
Key changes:
- New CutOverSource struct with DB, ReplClient, Tables
- NewCutOver accepts []CutOverSource
- algorithmCutover locks all sources, flushes all feeds, checks
all changes flushed, then renames per source
- On partial rename failure, completed renames are rolled back
by reversing the RENAME TABLE statements
The runner wraps its single source into []CutOverSource{...} for
backward compatibility. No behavioral change for 1:1 moves.
c1f7871 to
65ec27b
Compare
…me-named tables in different schemas Confirms that LOCK TABLES on t1 in schema_0 and LOCK TABLES on t1 in schema_1 can be held concurrently on the same MySQL server, since each connection is scoped to its own database. This is required for N:M move operations where multiple source databases have identically-named tables.
Merged
Kiran01bm
reviewed
Apr 13, 2026
Kiran01bm
reviewed
Apr 14, 2026
Kiran01bm
approved these changes
Apr 14, 2026
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.
A Pull Request should be associated with an Issue.
Part of #690
Refactor CutOver to accept []CutOverSource instead of a single db/feed pair. This prepares the cutover for N:M move operations where multiple source databases need to be locked, flushed, and renamed atomically.
Key changes:
The runner wraps its single source into []CutOverSource{...} for backward compatibility. No behavioral change for 1:1 moves.