Repository navigation
mysqlctl: stop incremental restore when file extraction fails - #22179
shashi1973 wants to merge 1 commit into
Conversation
Signed-off-by: Shashishekar Hullahally Anantharamu <39974616+shashi1973@users.noreply.github.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the change to prevent binlog replay after backup extraction fails.
No open issues 🎉
What changed in this PR
Fixes incremental restore error handling in mysqlctl for #21954, preventing binlog replay after backup-file extraction fails.
Changes:
- Checks extraction errors before replay, preserving the original failure.
- Retains the staging directory path on failure so deferred cleanup can remove it.
- Adds a regression test verifying error reporting and staging-directory cleanup after a storage read failure.
| File | Description |
|---|---|
go/vt/mysqlctl/builtinbackupengine.go |
Returns extraction errors before replay and preserves staging paths for cleanup. |
go/vt/mysqlctl/builtinbackupengine_test.go |
Adds regression coverage for storage read failures and cleanup. |
Review effort: Balanced
|
Hi @mattlord, I’ve opened #22179 with the fix and regression test for this issue. The focused tests passed locally on my Mac, and the PR includes the earlier validation results for both release branches. I’ve requested backports to |
mattlord
left a comment
There was a problem hiding this comment.
Thanks for picking this up!
Blocking: I think that we should test the staging-directory cleanup on each error path that now returns createdDir, or make that cleanup independent of the path. The new test exercises only one of the six changed returns in restoreFiles (go/vt/mysqlctl/builtinbackupengine.go:1565-1605): its read failure is retried once and then fails at the retry's return createdDir, err (line 1600). Changing any of the other five back to return "", ... leaves every test passing. Three of those paths can be reached in an incremental restore: createChunkedDestinations failing on bad chunk metadata (line 1565), a fatal FAILED_PRECONDITION error such as a chunk's decompressed size mismatch (line 1570), and a context that is canceled before any file is dispatched (line 1574). I wonder if the simplest fix is to have executeRestoreIncrementalBackup create the staging directory itself, defer os.RemoveAll(createdDir) right away, and pass the directory to restoreFiles, which would then return only an error (the full restore passes ""). Every error path would then clean up by construction. The six return changes and the createdDir != "" guard would go away, since os.RemoveAll("") already does nothing, and the new test would cover the cleanup unchanged. I tried that locally: the targeted tests pass on macOS, and the Linux-only TestRestoreIncrementalBackupBuffered only needs to pass its own t.TempDir() (it vets with GOOS=linux). Otherwise, turning the new test into a table over those failure modes would close the gap. What do you think?
Locally, the full go/vt/mysqlctl package passes on macOS.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22179 +/- ##
===========================================
- Coverage 69.67% 66.95% -2.72%
===========================================
Files 1614 50 -1564
Lines 216793 7934 -208859
===========================================
- Hits 151044 5312 -145732
+ Misses 65749 2622 -63127
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Return the original backup-file extraction error before attempting incremental binlog replay, and clean up the temporary staging directory when extraction fails.
Previously,
restoreFilesdiscarded the staging path on failure, andexecuteRestoreIncrementalBackupchecked the extraction error after the replay loop. This could mask the original error and allow binlog paths to resolve against the tablet’s live binlog directory.The fix checks the error immediately and preserves the staging path for deferred cleanup. A regression test injects a backup-storage read failure and verifies the original error is reported and the staging directory is removed.
Motivation
How do you use Vitess?
Did you run this change against a real Vitess deployment?
Validation used
FakeBackupHandlewith the actual incremental restore helper. No live MySQL point-in-time restore was performed.On unpatched main, the regression returned
expected: Mysqldinstead of the storage error and left a staging directory. It passed with the fix.Related Issue(s)
Fixes #21954
Backport request
Please consider backporting this fix to
release-23.0andrelease-24.0.The faulty error-check ordering is present in v16.0.0, which introduced incremental restore through #11097, and remains in both release branches. The fix prevents replay after failed extraction, preserves the original error, and removes temporary staging files.
Separate local backport patches passed the regression and file-path test against these branch baselines:
release-23.0at9adccbcfca6644b2bef1686bfa1fb7c038327162release-24.0at42d00a0cb2af97a3078be677fd0d7c6853c926a3Testing
The following focused tests passed on the refreshed main baseline and on my Mac with Go 1.27.4:
Mac result:
The repository formatter and
git diff --checkalso passed. The complete mysqlctl suite was attempted in the assistant workspace but encountered Unix-socket listener restrictions.Checklist
Deployment Notes
No configuration changes are required.
AI Disclosure
An OpenAI coding assistant helped prepare the implementation, regression test, and validation notes. I applied the patch and ran the focused tests locally on my Mac.