From 43a1419b075bf45e57e85699ac905f9f91ece1c3 Mon Sep 17 00:00:00 2001 From: liuchengyu Date: Mon, 4 Mar 2024 11:31:25 +0800 Subject: [PATCH] fix: master has db data, but no binlog. a new slave has replication_id in its config. this must execute full sync(#2436) --- src/pika_repl_server_conn.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pika_repl_server_conn.cc b/src/pika_repl_server_conn.cc index 21847db3cd..78b2b8638d 100644 --- a/src/pika_repl_server_conn.cc +++ b/src/pika_repl_server_conn.cc @@ -202,6 +202,13 @@ bool PikaReplServerConn::TrySyncOffsetCheck(const std::shared_ptr& return false; } + if (boffset.filenum == slave_boffset.filenum() && slave_boffset.filenum() == 0 && + boffset.offset == slave_boffset.offset() && slave_boffset.offset() == 0) { + LOG(INFO) << "maybe a new master and slave, there is no binlog, but has db data, this need full sync"; + try_sync_response->set_reply_code(InnerMessage::InnerResponse::TrySync::kSyncPointBePurged); + return false; + } + PikaBinlogReader reader; reader.Seek(db->Logger(), slave_boffset.filenum(), slave_boffset.offset()); BinlogOffset seeked_offset;