mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
feat(replication): Use a ring buffer with messages to serve replication. (#1835)
* feat(replication): Use a ring buffer with messages to serve replication. * Fix libraries dep graph * Address PR feedback * nits * add a comment * Lower the default log length
This commit is contained in:
parent
1e61ec8114
commit
db21b735f6
16 changed files with 127 additions and 65 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "server/rdb_load.h"
|
||||
|
||||
#include "absl/strings/escaping.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include "redis/intset.h"
|
||||
|
@ -2147,20 +2149,28 @@ error_code RdbLoaderBase::HandleJournalBlob(Service* service) {
|
|||
while (done < num_entries) {
|
||||
journal::ParsedEntry entry{};
|
||||
SET_OR_RETURN(journal_reader_.ReadEntry(), entry);
|
||||
done++;
|
||||
|
||||
if (!entry.cmd.cmd_args.empty()) {
|
||||
if (absl::EqualsIgnoreCase(facade::ToSV(entry.cmd.cmd_args[0]), "FLUSHALL") ||
|
||||
absl::EqualsIgnoreCase(facade::ToSV(entry.cmd.cmd_args[0]), "FLUSHDB")) {
|
||||
// Applying a flush* operation in the middle of a load can cause out-of-sync deletions of
|
||||
// data that should not be deleted, see https://github.com/dragonflydb/dragonfly/issues/1231
|
||||
// By returning an error we are effectively restarting the replication.
|
||||
return RdbError(errc::unsupported_operation);
|
||||
}
|
||||
// EXEC entries are just for preserving atomicity of transactions. We don't create
|
||||
// transactions and we don't care about atomicity when we're loading an RDB, so skip them.
|
||||
// Currently rdb_save also filters those records out, but we filter them additionally here
|
||||
// for better forward compatibility if we decide to change that.
|
||||
if (entry.opcode == journal::Op::EXEC)
|
||||
continue;
|
||||
|
||||
if (entry.cmd.cmd_args.empty())
|
||||
return RdbError(errc::rdb_file_corrupted);
|
||||
|
||||
if (absl::EqualsIgnoreCase(facade::ToSV(entry.cmd.cmd_args[0]), "FLUSHALL") ||
|
||||
absl::EqualsIgnoreCase(facade::ToSV(entry.cmd.cmd_args[0]), "FLUSHDB")) {
|
||||
// Applying a flush* operation in the middle of a load can cause out-of-sync deletions of
|
||||
// data that should not be deleted, see https://github.com/dragonflydb/dragonfly/issues/1231
|
||||
// By returning an error we are effectively restarting the replication.
|
||||
return RdbError(errc::unsupported_operation);
|
||||
}
|
||||
|
||||
VLOG(1) << "Executing item: " << entry.ToString();
|
||||
ex.Execute(entry.dbid, entry.cmd);
|
||||
VLOG(1) << "Reading item: " << entry.ToString();
|
||||
done++;
|
||||
}
|
||||
|
||||
return std::error_code{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue