Skip to content

Commit

Permalink
add some state transition based on reviewer's opinion
Browse files Browse the repository at this point in the history
  • Loading branch information
cheniujh committed Jul 1, 2024
1 parent 249be82 commit 6087180
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pika_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,15 @@ bool DB::TryUpdateMasterOffset() {
g_pika_rm->GetSyncSlaveDBByName(DBInfo(db_name_));
if (!slave_db) {
LOG(ERROR) << "Slave DB: " << db_name_ << " not exist";
slave_db->SetReplState(ReplState::kError);
return false;
}

std::string info_path = dbsync_path_ + kBgsaveInfoFile;
if (!pstd::FileExists(info_path)) {
LOG(WARNING) << "info path: " << info_path << " not exist, Slave DB:" << GetDBName() << " will restart the sync process...";
// May failed in RsyncClient, thus the complete snapshot dir got deleted
slave_db->SetReplState(kTryConnect);
slave_db->SetReplState(ReplState::kTryConnect);
return false;
}

Expand Down Expand Up @@ -477,6 +478,7 @@ bool DB::TryUpdateMasterOffset() {
g_pika_rm->GetSyncMasterDBByName(DBInfo(db_name_));
if (!master_db) {
LOG(WARNING) << "Master DB: " << db_name_ << " not exist";
slave_db->SetReplState(ReplState::kError);
return false;
}
master_db->Logger()->SetProducerStatus(filenum, offset);
Expand Down

0 comments on commit 6087180

Please sign in to comment.