Repository navigation
fix(storage): fsync the backup parent directory after rename - #3838
Closed
dragonknightk wants to merge 1 commit into
Closed
dragonknightk wants to merge 1 commit into
dragonknightk wants to merge 1 commit into
Conversation
## Issue Closes issue 3836 ## Description After renaming the new checkpoint into backup-dir, CreateBackup now fsyncs the parent directory, because without that fsync a power cut can leave the previous backup there after the call has already returned OK. If opening or fsyncing the parent fails, return an error so BGSAVE does not report ok. The DestroyDB unlinks just before the rename live in the same parent, so one fsync after the rename also covers them. The window between DestroyDB and the rename is left unchanged, because CreateBackup has not returned OK yet. RocksDB's Checkpoint already fsyncs the checkpoint directory itself after it is created under backup-dir.tmp. That does not persist the later rename of that directory into backup-dir. ## Tests The existing Storage.* tests pass. Storage's Env is fixed to Env::Default(), so a failing fsync cannot be injected, and no new test was added. Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com>
|
Hi @dragonknightk, Thank you for your pull request. Please review our Contributing Guide. Please make sure you understand your changes and explain your reasoning in this pull request. Low-quality pull requests may be closed. |
Member
|
Don't need to fix this issue, explains in issue. |
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.
Issue
closes #3836
Description
After renaming the new checkpoint into backup-dir, CreateBackup now fsyncs the parent directory, because without that fsync a power cut can leave the previous backup there after the call has already returned OK.
If opening or fsyncing the parent fails, return an error so BGSAVE does not report ok. The DestroyDB unlinks just before the rename live in the same parent, so one fsync after the rename also covers them. The window between DestroyDB and the rename is left unchanged, because CreateBackup has not returned OK yet.
RocksDB's Checkpoint already fsyncs the checkpoint directory itself after it is created under backup-dir.tmp. That does not persist the later rename of that directory into backup-dir.
Tests
The existing Storage.* tests pass. Storage's Env is fixed to Env::Default(), so a failing fsync cannot be injected, and no new test was added.
AI usage
Grok Bot, working for dragonknightk, assisted with the changes, the description, and the verification. All content was reviewed by a human, and the submitter understands and can maintain these changes.