Skip to content

Commit

Permalink
when receive unrecognizable binlog, disconnect the connection without…
Browse files Browse the repository at this point in the history
… change the status to SyncError (OpenAtomFoundation#331)
  • Loading branch information
Axlgrep authored Aug 20, 2018
1 parent 469f131 commit 58f149c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
1 change: 0 additions & 1 deletion include/pika_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class PikaServer {

void DoTimingTask();

slash::Mutex slaveping_protector_;
PikaSlavepingThread* ping_thread_;

/*
Expand Down
1 change: 0 additions & 1 deletion src/pika_new_master_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ pink::ReadStatus PikaNewMasterConn::GetRequest() {

if (type != kTypeAuth && type != kTypeBinlog) {
LOG(INFO) << "Unrecognizable Type: " << type << " maybe identify binlog type error";
g_pika_server->SyncError();
return pink::kParseError;
}

Expand Down
40 changes: 15 additions & 25 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ PikaServer::~PikaServer() {
}

delete pika_trysync_thread_;
{
slash::MutexLock l(&slaveping_protector_);
delete ping_thread_;
ping_thread_ = NULL;
}
delete ping_thread_;
delete pika_binlog_receiver_thread_;
delete pika_pubsub_thread_;

Expand Down Expand Up @@ -704,17 +700,14 @@ void PikaServer::SyncError() {
slash::RWLock l(&state_protector_, true);
repl_state_ = PIKA_REPL_ERROR;
}
{
slash::MutexLock l(&slaveping_protector_);
if (ping_thread_ != NULL) {
int err = ping_thread_->StopThread();
if (err != 0) {
std::string msg = "can't join thread " + std::string(strerror(err));
LOG(WARNING) << msg;
}
delete ping_thread_;
ping_thread_ = NULL;
if (ping_thread_ != NULL) {
int err = ping_thread_->StopThread();
if (err != 0) {
std::string msg = "can't join thread " + std::string(strerror(err));
LOG(WARNING) << msg;
}
delete ping_thread_;
ping_thread_ = NULL;
}
LOG(WARNING) << "Sync error, set repl_state to PIKA_REPL_ERROR";
}
Expand All @@ -733,17 +726,14 @@ void PikaServer::RemoveMaster() {
master_ip_ = "";
master_port_ = -1;
}
{
slash::MutexLock l(&slaveping_protector_);
if (ping_thread_ != NULL) {
int err = ping_thread_->StopThread();
if (err != 0) {
std::string msg = "can't join thread " + std::string(strerror(err));
LOG(WARNING) << msg;
}
delete ping_thread_;
ping_thread_ = NULL;
if (ping_thread_ != NULL) {
int err = ping_thread_->StopThread();
if (err != 0) {
std::string msg = "can't join thread " + std::string(strerror(err));
LOG(WARNING) << msg;
}
delete ping_thread_;
ping_thread_ = NULL;
}
{
slash::RWLock l(&state_protector_, true);
Expand Down

0 comments on commit 58f149c

Please sign in to comment.