Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: abnormal log output when exec slaveof no one #2801

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/pika_rm.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class PikaReplicaManager {
void RmStatus(std::string* debug_info);
pstd::Status CheckDBRole(const std::string& table, int* role);
pstd::Status LostConnection(const std::string& ip, int port);
pstd::Status DeactivateSyncSlaveDB(const std::string& ip, int port);

// Update binlog win and try to send next binlog
pstd::Status UpdateSyncBinlogStatus(const RmNode& slave, const LogOffset& offset_start, const LogOffset& offset_end);
Expand Down
11 changes: 11 additions & 0 deletions src/pika_rm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,17 @@ bool PikaReplicaManager::CheckSlaveDBState(const std::string& ip, const int port
return true;
}

Status PikaReplicaManager::DeactivateSyncSlaveDB(const std::string& ip, int port) {
std::shared_lock l(dbs_rw_);
for (auto& iter : sync_slave_dbs_) {
std::shared_ptr<SyncSlaveDB> db = iter.second;
if (db->MasterIp() == ip && db->MasterPort() == port) {
db->Deactivate();
}
}
return Status::OK();
}

Status PikaReplicaManager::LostConnection(const std::string& ip, int port) {
std::shared_lock l(dbs_rw_);
for (auto& iter : sync_master_dbs_) {
Expand Down
2 changes: 1 addition & 1 deletion src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ void PikaServer::RemoveMaster() {

if (!master_ip_.empty() && master_port_ != -1) {
g_pika_rm->CloseReplClientConn(master_ip_, master_port_ + kPortShiftReplServer);
g_pika_rm->LostConnection(master_ip_, master_port_);
g_pika_rm->DeactivateSyncSlaveDB(master_ip_, master_port_);
UpdateMetaSyncTimestampWithoutLock();
LOG(INFO) << "Remove Master Success, ip_port: " << master_ip_ << ":" << master_port_;
}
Expand Down
Loading