Skip to content

Commit

Permalink
bugfix:check slave partition state after dbslaveof no one (OpenAtomFo…
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelai authored and whoiami committed Mar 20, 2020
1 parent 2a6b1f0 commit 51a5826
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/pika_rm.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class PikaReplicaManager {

void RmStatus(std::string* debug_info);

bool CheckSlaveDBConnect();
static bool CheckSlavePartitionState(const std::string& ip, const int port);

Status LostConnection(const std::string& ip, int port);

Expand Down
2 changes: 1 addition & 1 deletion src/pika_repl_client_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void PikaReplClientThread::ReplClientHandle::FdTimeoutHandle(int fd, const std::
if (ip == g_pika_server->master_ip()
&& port == g_pika_server->master_port() + kPortShiftReplServer
&& PIKA_REPL_ERROR != g_pika_server->repl_state()
&& g_pika_rm->CheckSlaveDBConnect()) { // if state machine in error state, no retry
&& g_pika_rm->CheckSlavePartitionState(ip, port)) { // if state machine in error state, no retry
LOG(WARNING) << "Master conn timeout : " << ip_port << " try reconnect";
g_pika_server->ResetMetaSyncStatus();
g_pika_server->UpdateMetaSyncTimestamp();
Expand Down
5 changes: 3 additions & 2 deletions src/pika_rm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -797,11 +797,12 @@ Status PikaReplicaManager::UpdateSyncBinlogStatus(const RmNode& slave, const Bin
return Status::OK();
}

bool PikaReplicaManager::CheckSlaveDBConnect() {
bool PikaReplicaManager::CheckSlavePartitionState(const std::string& ip, const int port) {
std::shared_ptr<SyncSlavePartition> partition = nullptr;
for (auto iter : g_pika_rm->sync_slave_partitions_) {
partition = iter.second;
if (partition->State() == ReplState::kDBNoConnect) {
if (partition->State() == ReplState::kDBNoConnect &&
partition->MasterIp() == ip && partition->MasterPort() + kPortShiftReplServer == port) {
LOG(INFO) << "DB: " << partition->SyncPartitionInfo().ToString()
<< " has been dbslaveof no one, then will not try reconnect.";
return false;
Expand Down

0 comments on commit 51a5826

Please sign in to comment.