-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Resume from checkpoint #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Resume from checkpoint #1595
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d6ee06d
add Checkpoint table and read/write funcs
meiji163 e2f0a20
handle no checkpoints returned
meiji163 7c5fda8
store min and max range values in checkpoint
meiji163 713ce97
resume from checkpoint
meiji163 a292d24
add checkpoint file
meiji163 cec7f8d
Merge branch 'master' into checkpoint
meiji163 9012df0
fix unique key args
meiji163 c1fae0b
update applier coordinates from _ghc heartbeat
meiji163 93953c9
fix test
meiji163 02f885f
fix linter
meiji163 8c2ad77
make checkpoint interval configurable
meiji163 d4ac082
write checkpoint iteration number
meiji163 43e0d2c
store rows copied & dml applied
meiji163 4c7ed5f
truncate column name if necessary
meiji163 5284301
drop checkpoint table for final cleanup
meiji163 5662d9b
add docs
meiji163 bcd19da
add resume doc
meiji163 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Resuming Migrations | ||
|
|
||
| `gh-ost` can attempt to resume an interrupted migration from a checkpoint if the following conditions are met: | ||
| - The first `gh-ost` process was invoked with `--checkpoint` | ||
| - The first `gh-ost` process had at least one successful checkpoint | ||
| - The binlogs from the last checkpoint's binlog coordinates still exist on the replica gh-ost is inspecting (specified by `--host`) | ||
|
|
||
| To resume, invoke `gh-ost` again with the same arguments with the `--resume` flag. | ||
|
|
||
| > [!WARNING] | ||
| > It is recommended use `--checkpoint` with `--gtid` enabled so that checkpoint binlog coordinates store GTID sets rather than file positions. In that case, `gh-ost` can resume using a different replica than it originally attached to. | ||
|
|
||
| ## Example | ||
| The migration starts with a `gh-ost` invocation such as: | ||
| ```shell | ||
| gh-ost \ | ||
| --chunk-size=100 \ | ||
| --host=replica1.company.com \ | ||
| --database="mydb" \ | ||
| --table="mytable" \ | ||
| --alter="add column mycol varchar(20)" | ||
| --gtid \ | ||
| --checkpoint \ | ||
| --checkpoint-seconds=60 \ | ||
| --execute | ||
| ``` | ||
|
|
||
| In this example `gh-ost` writes a checkpoint to a table `_mytable_ghk` every 60 seconds. After `gh-ost` is interrupted/killed, the migration can be resumed with: | ||
| ```shell | ||
| # resume migration | ||
| gh-ost \ | ||
| --chunk-size=100 | ||
| --host=replica1.company.com \ | ||
| --database="mydb" \ | ||
| --table="mytable" \ | ||
| --alter="add column mycol varchar(20)" | ||
| --gtid \ | ||
| --resume \ | ||
| --execute | ||
| ``` | ||
|
|
||
| `gh-ost` then reconnects at the binlog coordinates of the last checkpoint and resumes copying rows at the chunk specified by the checkpoint. The data integrity of the ghost table is preserved because `gh-ost` applies row DMLs and copies row in an idempotent way. |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.