Skip to content

Commit 9b34c09

Browse files
pdillingerfacebook-github-bot
authored andcommitted
Fix bug updating latest backup on delete (#11029)
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
1 parent 00238a3 commit 9b34c09

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Fixed a memory leak in MultiGet with async_io read option, caused by IO errors during table file open
99
* 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.
1010
* 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).
11+
* Fixed a BackupEngine bug in which RestoreDBFromLatestBackup would fail if the latest backup was deleted and there is another valid backup available.
1112

1213
## 7.9.0 (11/21/2022)
1314
### Performance Improvements

utilities/backup/backup_engine.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,11 @@ IOStatus BackupEngineImpl::DeleteBackupNoGC(BackupID backup_id) {
16351635
return io_s;
16361636
}
16371637
backups_.erase(backup);
1638+
if (backups_.empty()) {
1639+
latest_valid_backup_id_ = 0;
1640+
} else {
1641+
latest_valid_backup_id_ = backups_.rbegin()->first;
1642+
}
16381643
} else {
16391644
auto corrupt = corrupt_backups_.find(backup_id);
16401645
if (corrupt == corrupt_backups_.end()) {

utilities/backup/backup_engine_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,10 @@ TEST_P(BackupEngineTestWithParam, OnlineIntegrationTest) {
12131213
// check backup 5
12141214
AssertBackupConsistency(5, 0, max_key);
12151215

1216+
// check that "latest backup" still works after deleting latest
1217+
ASSERT_OK(backup_engine_->DeleteBackup(5));
1218+
AssertBackupConsistency(0, 0, 3 * keys_iteration, max_key);
1219+
12161220
CloseBackupEngine();
12171221
}
12181222
#endif // !defined(ROCKSDB_VALGRIND_RUN) || defined(ROCKSDB_FULL_VALGRIND_RUN)

0 commit comments

Comments
 (0)