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:
parent
5750c0d334
commit
1fa5340c27
3 changed files with 10 additions and 1 deletions
|
@ -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_);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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_);
|
||||
|
|
Loading…
Reference in a new issue