Skip to content

Commit 6a22902

Browse files
committed
raft: clarify AckApplying and AckApplied semantics
Epic: none Release note: none
1 parent df64577 commit 6a22902

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pkg/raft/rawnode.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,24 @@ func newStorageAppendRespMsg(r *raft, rd Ready) pb.Message {
396396

397397
// AckApplying accepts all committed entries <= index as being applied to the
398398
// state machine. The caller gives a promise to eventually apply these entries
399-
// and call AckApplied to confirm. They can do so asynchronously.
399+
// and call AckApplied to confirm. They can do so asynchronously, while this
400+
// RawNode keeps making progress.
400401
//
401-
// AckApplying prevents committed indices <= index from causing Ready.
402+
// It is allowed to never call AckApplying, and call AckApplied straight away.
403+
// Technically, AckApplying only prevents committed indices <= index from
404+
// causing Ready signals.
405+
//
406+
// Requires: all AckApplying calls must have increasing indices.
407+
// Requires: index <= Ready.Committed.Last. That is, the caller can only accept
408+
// "apply-able" entries that it learns about from Ready().
402409
func (rn *RawNode) AckApplying(index pb.Index) {
403410
rn.raft.raftLog.acceptApplying(uint64(index))
404411
}
405412

406413
// AckApplied acknowledges that the given entries have been applied. Must be
407-
// called for a prefix of Ready.Committed span, during the ready handling.
414+
// called for every span of applied entries, in order. If the caller chose to
415+
// apply entries asynchronously, they should synchronize the order of these
416+
// calls with applying snapshots.
408417
func (rn *RawNode) AckApplied(entries []pb.Entry) {
409418
if len(entries) == 0 {
410419
return

0 commit comments

Comments
 (0)