Skip to content

Commit 112c9ec

Browse files
committed
Make leader reset the byte progress of peers that were receiving the compacted entries.
1 parent 5edb28f commit 112c9ec

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/raft.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,15 @@ static int raft_compact(raft_t raft) {
639639
e->bytes = e->update.len;
640640
e->snapshot = true;
641641
assert(l->first == l->applied - 1);
642+
643+
// reset bytes progress of peers that were receiving the compacted entries
644+
for (int i = 0; i < raft->config.peernum_max; i++) {
645+
raft_peer_t *p = raft->peers + i;
646+
if (!p->up) continue;
647+
if (i == raft->me) continue;
648+
if (p->acked.entries + 1 <= l->first)
649+
p->acked.bytes = 0;
650+
}
642651
}
643652
return compacted;
644653
}

0 commit comments

Comments
 (0)