diff --git a/src/replication.cc b/src/replication.cc index 1ced8346302..716872f8308 100644 --- a/src/replication.cc +++ b/src/replication.cc @@ -277,7 +277,7 @@ Status ReplicationThread::Start(std::function &&pre_fullsync_cb, pre_fullsync_cb_ = std::move(pre_fullsync_cb); post_fullsync_cb_ = std::move(post_fullsync_cb); - // Clean synced checkpoint fronm old master because replica starts to follow new master + // Clean synced checkpoint from old master because replica starts to follow new master auto s = rocksdb::DestroyDB(srv_->GetConfig()->sync_checkpoint_dir, rocksdb::Options()); if (!s.ok()) { LOG(WARNING) << "Can't clean synced checkpoint from master, error: " << s.ToString(); diff --git a/src/storage.cc b/src/storage.cc index 7a7b5f7cce3..552bf52bd5a 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -318,17 +318,6 @@ Status Storage::RestoreFromBackup() { return s.ok() ? Status::OK() : Status(Status::DBBackupErr, s.ToString()); } -Status Storage::Reopen() { - auto s = Open(); - if (!s.IsOK()) { - LOG(ERROR) << "[storage] Fail to reopen db, error: " << s.Msg(); - LOG(ERROR) << "[storage] Exiting..."; - exit(1); - } - LOG(INFO) << "[storage] Succeed reopening db"; - return Status::OK(); -} - Status Storage::RestoreFromCheckpoint() { std::string dir = config_->sync_checkpoint_dir; std::string tmp_dir = config_->db_dir + ".tmp"; @@ -345,14 +334,14 @@ Status Storage::RestoreFromCheckpoint() { // But only try best effort to make data safe auto s = backup_env_->RenameFile(config_->db_dir, tmp_dir); if (!s.ok()) { - Reopen(); + if (!Open().IsOK()) LOG(ERROR) << "[storage] Fail to reopen db"; return Status(Status::NotOK, "Fail to rename db dir, error: " + s.ToString()); } // Rename checkpoint dir to db dir if (!(s = backup_env_->RenameFile(dir, config_->db_dir)).ok()) { backup_env_->RenameFile(tmp_dir, config_->db_dir); - Reopen(); + if (!Open().IsOK()) LOG(ERROR) << "[storage] Fail to reopen db"; return Status(Status::NotOK, "Fail to rename checkpoint dir, error: " + s.ToString()); } @@ -362,7 +351,7 @@ Status Storage::RestoreFromCheckpoint() { LOG(WARNING) << "[storage] Fail to open master checkpoint, error: " << s2.Msg(); rocksdb::DestroyDB(config_->db_dir, rocksdb::Options()); backup_env_->RenameFile(tmp_dir, config_->db_dir); - Reopen(); + if (!Open().IsOK()) LOG(ERROR) << "[storage] Fail to reopen db"; return Status(Status::DBOpenErr, "Fail to open master checkpoint, error: " + s2.Msg()); } diff --git a/src/storage.h b/src/storage.h index 0aeb39dcfd0..a55f1b11890 100644 --- a/src/storage.h +++ b/src/storage.h @@ -37,7 +37,6 @@ class Storage { Status Open(bool read_only); Status Open(); - Status Reopen(); Status OpenForReadOnly(); void CloseDB(); void InitOptions(rocksdb::Options *options);