Skip to content

Commit

Permalink
Fix read-only DB writing to filesystem with write_dbid_to_manifest (#…
Browse files Browse the repository at this point in the history
…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: #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
  • Loading branch information
pdillinger authored and facebook-github-bot committed Apr 7, 2021
1 parent 35af043 commit a4e82a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db/db_impl/db_impl_files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions utilities/backupable/backupable_db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<BackupInfo> backup_info;
Expand Down

0 comments on commit a4e82a3

Please sign in to comment.