Persist right after loading dump

master
Vitaliy Filippov 2024-05-09 18:29:14 +03:00
parent 84533dc9ef
commit bb4935641a
1 changed files with 6 additions and 2 deletions

View File

@ -373,7 +373,7 @@ class AntiCluster
}
else if (msg.load)
{
this._handleLoadMsg(client, msg);
this._handleLoadMsg(client, msg).catch(console.error);
}
else if (msg.replicate)
{
@ -419,12 +419,16 @@ class AntiCluster
}
}
_handleLoadMsg(client, msg)
async _handleLoadMsg(client, msg)
{
if (client.raft_node_id && this.raft.state == TinyRaft.FOLLOWER &&
this.raft.leader === client.raft_node_id && this.raft.term == msg.term)
{
this.antietcd.etctree.load(msg.load);
if (this.antietcd.persistence)
{
await this.antietcd.persistence.persist();
}
this.antietcd.stored_term = msg.term;
this.synced = true;
runCallbacks(this, 'wait_sync', []);