diff --git a/db/db_impl/db_impl_files.cc b/db/db_impl/db_impl_files.cc index c71dc8c83b9..42f9c0683d8 100644 --- a/db/db_impl/db_impl_files.cc +++ b/db/db_impl/db_impl_files.cc @@ -890,7 +890,7 @@ Status DBImpl::SetDBId(bool read_only) { mutable_cf_options, &edit, &mutex_, nullptr, /* new_descriptor_log */ false); } - } else { + } else if (!read_only) { s = SetIdentityFile(env_, dbname_, db_id_); } return s; diff --git a/utilities/backupable/backupable_db_test.cc b/utilities/backupable/backupable_db_test.cc index 7d24936f504..fdaf4a149f5 100644 --- a/utilities/backupable/backupable_db_test.cc +++ b/utilities/backupable/backupable_db_test.cc @@ -2616,11 +2616,17 @@ TEST_F(BackupableDBTest, ReadOnlyBackupEngine) { TEST_F(BackupableDBTest, OpenBackupAsReadOnlyDB) { DestroyDB(dbname_, options_); + options_.write_dbid_to_manifest = false; + OpenDBAndBackupEngine(true); 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); - ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), true)); + ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), /*flush*/ false)); db_.reset(); // CloseDB DestroyDB(dbname_, options_); std::vector backup_info;