Wait until all committed entries are applied

To take a snapshot
This commit is contained in:
Shintaro Murakami 2021-02-05 09:33:53 +09:00
parent cb14cdd774
commit be2167ebab

View File

@ -340,6 +340,15 @@ func (rc *raftNode) maybeTriggerSnapshot() {
return
}
// wait until all committed entries are applied
// commitC is synchronous channel, so consumption of the message signals
// full application of previous messages
select {
case rc.commitC <- nil:
case <-rc.stopc:
return
}
log.Printf("start snapshot [applied index: %d | last snapshot index: %d]", rc.appliedIndex, rc.snapshotIndex)
data, err := rc.getSnapshot()
if err != nil {