]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fix bug updating latest backup on delete (#11029)
authorPeter Dillinger <peterd@fb.com>
Tue, 13 Dec 2022 17:42:34 +0000 (09:42 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 13 Dec 2022 17:42:34 +0000 (09:42 -0800)
Summary:
Previously, the "latest" valid backup would not be updated on delete.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/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

HISTORY.md
utilities/backup/backup_engine.cc
utilities/backup/backup_engine_test.cc

index b2db0c216404692e6d128882cdedac51b1b37896..b762388aa10d8d70e350ac7d6d7bb988625e817f 100644 (file)
@@ -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
index 81b4a662935d3198f151b803d8f4ffe4f69086a3..6f1f19c2b22116cfa48a3e4772b9ccec49923ef6 100644 (file)
@@ -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()) {
index d1f74f769a22b4f53f479ef1e852a4f26611289b..01a3a18052dbd11673a501c981aa9a411c045fe2 100644 (file)
@@ -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)