Skip to content

Commit 46a398d

Browse files
committed
Solve the bug that the slave node also generates Binlog
1 parent 103e86e commit 46a398d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/pika_repl_bgworker.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,11 @@ void PikaReplBgWorker::HandleBGWorkerWriteBinlog(void* arg) {
215215
if (only_keepalive) {
216216
ack_end = LogOffset();
217217
} else {
218-
LogOffset productor_status;
219-
// Reply Ack to master immediately
220-
std::shared_ptr<Binlog> logger = db->Logger();
221-
logger->GetProducerStatus(&productor_status.b_offset.filenum, &productor_status.b_offset.offset,
222-
&productor_status.l_offset.term, &productor_status.l_offset.index);
223-
ack_end = productor_status;
224-
ack_end.l_offset.term = pb_end.l_offset.term;
218+
// The slave node uses the binlog offset sent by the master node as ACK
219+
ack_end = pb_end;
225220

226221
// slave nodes batch Binlog flush disk
222+
std::shared_ptr<Binlog> logger = db->Logger();
227223
logger->Sync();
228224
}
229225

@@ -266,7 +262,7 @@ int PikaReplBgWorker::HandleWriteBinlog(net::RedisParser* parser, const net::Red
266262
return -1;
267263
}
268264
if(db->GetISConsistency()){
269-
db->AppendSlaveEntries(c_ptr, worker->binlog_item_);
265+
PikaReplBgWorker::WriteDBInSyncWay(c_ptr);
270266
}else{
271267
db->ConsensusProcessLeaderLog(c_ptr, worker->binlog_item_);
272268
}

0 commit comments

Comments
 (0)