Skip to content

Commit

Permalink
Fix bug updating latest backup on delete (#11029)
Browse files Browse the repository at this point in the history
Summary:
Previously, the "latest" valid backup would not be updated on delete.

Pull Request resolved: #11029

Test Plan: unit test included (added to an existing test for efficiency)

Reviewed By: hx235

Differential Revision: D41967925

Pulled By: pdillinger

fbshipit-source-id: ca143354d281eb979557ea421902cd26803a1137
  • Loading branch information
pdillinger authored and facebook-github-bot committed Dec 13, 2022
1 parent 00238a3 commit 9b34c09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Fixed a memory leak in MultiGet with async_io read option, caused by IO errors during table file open
* Fixed a bug that multi-level FIFO compaction deletes one file in non-L0 even when `CompactionOptionsFIFO::max_table_files_size` is no exceeded since #10348 or 7.8.0.
* Fixed a bug caused by `DB::SyncWAL()` affecting `track_and_verify_wals_in_manifest`. Without the fix, application may see "open error: Corruption: Missing WAL with log number" while trying to open the db. The corruption is a false alarm but prevents DB open (#10892).
* Fixed a BackupEngine bug in which RestoreDBFromLatestBackup would fail if the latest backup was deleted and there is another valid backup available.

## 7.9.0 (11/21/2022)
### Performance Improvements
Expand Down
5 changes: 5 additions & 0 deletions utilities/backup/backup_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,11 @@ IOStatus BackupEngineImpl::DeleteBackupNoGC(BackupID backup_id) {
return io_s;
}
backups_.erase(backup);
if (backups_.empty()) {
latest_valid_backup_id_ = 0;
} else {
latest_valid_backup_id_ = backups_.rbegin()->first;
}
} else {
auto corrupt = corrupt_backups_.find(backup_id);
if (corrupt == corrupt_backups_.end()) {
Expand Down
4 changes: 4 additions & 0 deletions utilities/backup/backup_engine_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,10 @@ TEST_P(BackupEngineTestWithParam, OnlineIntegrationTest) {
// check backup 5
AssertBackupConsistency(5, 0, max_key);

// check that "latest backup" still works after deleting latest
ASSERT_OK(backup_engine_->DeleteBackup(5));
AssertBackupConsistency(0, 0, 3 * keys_iteration, max_key);

CloseBackupEngine();
}
#endif // !defined(ROCKSDB_VALGRIND_RUN) || defined(ROCKSDB_FULL_VALGRIND_RUN)
Expand Down

0 comments on commit 9b34c09

Please sign in to comment.