1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

fix(server): Flush dbs before full sync (#659)

This commit is contained in:
Vladislav 2023-01-09 12:11:17 +03:00 committed by GitHub
parent 5750c0d334
commit 1fa5340c27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -55,6 +55,11 @@ void JournalExecutor::Execute(DbIndex dbid, journal::ParsedEntry::CmdData& cmd)
Execute(cmd);
}
void JournalExecutor::FlushAll() {
auto cmd = BuildFromParts("FLUSHALL");
Execute(cmd);
}
void JournalExecutor::Execute(journal::ParsedEntry::CmdData& cmd) {
auto span = CmdArgList{cmd.cmd_args.data(), cmd.cmd_args.size()};
service_->DispatchCommand(span, &conn_context_);

View file

@ -17,6 +17,8 @@ class JournalExecutor {
void Execute(DbIndex dbid, std::vector<journal::ParsedEntry::CmdData>& cmds);
void Execute(DbIndex dbid, journal::ParsedEntry::CmdData& cmd);
void FlushAll(); // Execute FLUSHALL.
private:
void Execute(journal::ParsedEntry::CmdData& cmd);

View file

@ -467,9 +467,11 @@ error_code Replica::InitiateDflySync() {
RETURN_ON_ERR(cntx_.SwitchErrorHandler(std::move(err_handler)));
// Make sure we're in LOADING state.
// TODO: Flush db on retry.
CHECK(service_.SwitchState(GlobalState::ACTIVE, GlobalState::LOADING) == GlobalState::LOADING);
// Flush dbs.
JournalExecutor{&service_}.FlushAll();
// Start full sync flows.
{
auto partition = Partition(num_df_flows_);