feat(server): check master journal lsn in replica (#2778)

Send journal lsn to replica and compare the lsn value against number of records received in replica side

Signed-off-by: kostas <kostas@dragonflydb.io>
Co-authored-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
Kostas Kyrimis 2024-04-01 17:51:31 +03:00 committed by GitHub
parent 3ec43afd30
commit b2e2ad6e04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 77 additions and 37 deletions

View file

@ -75,6 +75,8 @@ void JournalWriter::Write(const journal::Entry& entry) {
switch (entry.opcode) {
case journal::Op::SELECT:
return Write(entry.dbid);
case journal::Op::LSN:
return Write(entry.lsn);
case journal::Op::PING:
return;
case journal::Op::COMMAND:
@ -199,6 +201,11 @@ io::Result<journal::ParsedEntry> JournalReader::ReadEntry() {
return entry;
}
if (opcode == journal::Op::LSN) {
SET_OR_UNEXPECT(ReadUInt<uint64_t>(), entry.lsn);
return entry;
}
SET_OR_UNEXPECT(ReadUInt<uint64_t>(), entry.txid);
SET_OR_UNEXPECT(ReadUInt<uint32_t>(), entry.shard_cnt);