fix: protect OnJournalEntry with ConditionGuard (#3367)

* add ConditionGuard on JournalEntry such that the stream state stays consistent

Signed-off-by: kostas <kostas@dragonflydb.io>
This commit is contained in:
Kostas Kyrimis 2024-07-23 12:05:34 +03:00 committed by GitHub
parent cd0e03a737
commit bcdfccc039
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -386,6 +386,7 @@ void SliceSnapshot::OnJournalEntry(const journal::JournalItem& item, bool await)
// To enable journal flushing to sync after non auto journal command is executed we call // To enable journal flushing to sync after non auto journal command is executed we call
// TriggerJournalWriteToSink. This call uses the NOOP opcode with await=true. Since there is no // TriggerJournalWriteToSink. This call uses the NOOP opcode with await=true. Since there is no
// additional journal change to serialize, it simply invokes PushSerializedToChannel. // additional journal change to serialize, it simply invokes PushSerializedToChannel.
ConditionGuard guard(&bucket_ser_);
if (item.opcode != journal::Op::NOOP) { if (item.opcode != journal::Op::NOOP) {
serializer_->WriteJournalEntry(item.data); serializer_->WriteJournalEntry(item.data);
} }