Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 56ed20a

Browse files
committed
Prevent Raft followers from applying entries which they have not received yet.
1 parent 1552662 commit 56ed20a

File tree

1 file changed

+1
-1
lines changed
  • contrib/raftable/raft/src

1 file changed

+1
-1
lines changed

contrib/raftable/raft/src/raft.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ bool raft_peer_up(raft_t r, int id, char *host, int port, bool self) {
320320
static int raft_apply(raft_t raft) {
321321
int applied_now = 0;
322322
raft_log_t *l = &raft->log;
323-
while (l->applied < l->acked) {
323+
while ((l->applied < l->acked) && (l->applied <= RAFT_LOG_LAST_INDEX(raft))) {
324324
raft_entry_t *e = &RAFT_LOG(raft, l->applied);
325325
assert(e->update.len == e->bytes);
326326
raft->config.applier(raft->config.userdata, e->update, false);

0 commit comments

Comments
 (0)