bug server: fix lns mismatch in replication

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adi_holden 2025-04-23 14:24:28 +03:00
parent 7402730f71
commit 2e12d1f3d5
2 changed files with 5 additions and 9 deletions

View file

@ -57,14 +57,6 @@ void JournalStreamer::Start(util::FiberSocketBase* dest, bool send_lsn) {
dest_ = dest;
journal_cb_id_ =
journal_->RegisterOnChange([this, send_lsn](const JournalItem& item, bool allow_await) {
if (allow_await) {
ThrottleIfNeeded();
// No record to write, just await if data was written so consumer will read the data.
// TODO: shouldnt we trigger async write in noop??
if (item.opcode == Op::NOOP)
return;
}
if (!ShouldWrite(item)) {
return;
}
@ -81,6 +73,10 @@ void JournalStreamer::Start(util::FiberSocketBase* dest, bool send_lsn) {
writer.Write(Entry{journal::Op::LSN, item.lsn});
Write(std::move(sink).str());
}
if (allow_await) {
ThrottleIfNeeded();
}
});
}

View file

@ -48,7 +48,7 @@ class JournalStreamer {
void ThrottleIfNeeded();
virtual bool ShouldWrite(const journal::JournalItem& item) const {
return cntx_->IsRunning();
return cntx_->IsRunning() && item.opcode != journal::Op::NOOP;
}
void WaitForInflightToComplete();