Fix read-only DB writing to filesystem with write_dbid_to_manifest (#8164)

Summary:
Fixing another crash test failure in the case of
write_dbid_to_manifest=true and reading a backup as read-only DB.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8164

Test Plan:
enhanced unit test for backup as read-only DB, ran
blackbox_crash_test more with elevated backup_one_in

Reviewed By: zhichao-cao

Differential Revision: D27622237

Pulled By: pdillinger

fbshipit-source-id: 680d0f99ddb465a601737f2e3f2c80efd47384fb
main
Peter Dillinger 4 years ago committed by Facebook GitHub Bot
parent 35af0433cf
commit a4e82a3cca
  1. 2
      db/db_impl/db_impl_files.cc
  2. 10
      utilities/backupable/backupable_db_test.cc

@ -890,7 +890,7 @@ Status DBImpl::SetDBId(bool read_only) {
mutable_cf_options, &edit, &mutex_, nullptr, mutable_cf_options, &edit, &mutex_, nullptr,
/* new_descriptor_log */ false); /* new_descriptor_log */ false);
} }
} else { } else if (!read_only) {
s = SetIdentityFile(env_, dbname_, db_id_); s = SetIdentityFile(env_, dbname_, db_id_);
} }
return s; return s;

@ -2616,11 +2616,17 @@ TEST_F(BackupableDBTest, ReadOnlyBackupEngine) {
TEST_F(BackupableDBTest, OpenBackupAsReadOnlyDB) { TEST_F(BackupableDBTest, OpenBackupAsReadOnlyDB) {
DestroyDB(dbname_, options_); DestroyDB(dbname_, options_);
options_.write_dbid_to_manifest = false;
OpenDBAndBackupEngine(true); OpenDBAndBackupEngine(true);
FillDB(db_.get(), 0, 100); FillDB(db_.get(), 0, 100);
ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), true)); ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), /*flush*/ false));
options_.write_dbid_to_manifest = true; // exercises some read-only DB code
CloseAndReopenDB();
FillDB(db_.get(), 100, 200); FillDB(db_.get(), 100, 200);
ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), true)); ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), /*flush*/ false));
db_.reset(); // CloseDB db_.reset(); // CloseDB
DestroyDB(dbname_, options_); DestroyDB(dbname_, options_);
std::vector<BackupInfo> backup_info; std::vector<BackupInfo> backup_info;

Loading…
Cancel
Save