Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Condition that slave master conn is broken, slave feel that broken and
send metasync msg again. Master feel that broken after receiving slave's
metasync msg. Instead of reject slave's metasync request, master should
notice slave keep trying send metasync because next time master may feel
that broken conn, remove old slave node and accept this new metasync msg.
  • Loading branch information
whoiami authored May 27, 2020
1 parent a45a51a commit 31a8368
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/pika_inner_message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum Type {
enum StatusCode {
kOk = 1;
kError = 2;
kOther = 3;
}

message BinlogOffset {
Expand Down
8 changes: 8 additions & 0 deletions src/pika_repl_client_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ void PikaReplClientConn::HandleMetaSyncResponse(void* arg) {
std::shared_ptr<pink::PbConn> conn = task_arg->conn;
std::shared_ptr<InnerMessage::InnerResponse> response = task_arg->res;

if (response->code() == InnerMessage::kOther) {
std::string reply = response->has_reply() ? response->reply() : "";
// keep sending MetaSync
LOG(WARNING) << "Meta Sync Failed: " << reply << " will keep sending MetaSync msg";
return;
}

if (response->code() != InnerMessage::kOk) {
std::string reply = response->has_reply() ? response->reply() : "";
LOG(WARNING) << "Meta Sync Failed: " << reply;
Expand Down Expand Up @@ -279,6 +286,7 @@ Status PikaReplClientConn::TrySyncConsensusCheck(
return s;
}
slave_partition->SetReplState(ReplState::kTryConnect);

return s;
}

Expand Down
2 changes: 1 addition & 1 deletion src/pika_repl_server_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void PikaReplServerConn::HandleMetaSyncRequest(void* arg) {
const std::string ip_port = slash::IpPortString(node.ip(), node.port());
g_pika_rm->ReplServerUpdateClientConnMap(ip_port, conn->fd());
if (!success) {
response.set_code(InnerMessage::kError);
response.set_code(InnerMessage::kOther);
response.set_reply("Slave AlreadyExist");
} else {
g_pika_server->BecomeMaster();
Expand Down

0 comments on commit 31a8368

Please sign in to comment.