Content-Length: 279847 | pFad | http://github.com/postgrespro/postgres_cluster/commit/45143b6be4ce1aee9066b1d9be179f39f73b50ec

D5 Make follower refuse updates that have previndex too far in the future. · postgrespro/postgres_cluster@45143b6 · GitHub
Skip to content

Commit 45143b6

Browse files
committed
Make follower refuse updates that have previndex too far in the future.
1 parent 112c9ec commit 45143b6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/raft.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,12 @@ static void raft_handle_update(raft_t r, raft_msg_update_t *m) {
800800
reply.progress.entries = RAFT_LOG_LAST_INDEX(r) + 1;
801801
reply.progress.bytes = e->bytes;
802802

803+
if (m->previndex > RAFT_LOG_LAST_INDEX(r))
804+
{
805+
debug("got an update with previndex=%d > lastindex=%d\n", m->previndex, RAFT_LOG_LAST_INDEX(r));
806+
goto finish;
807+
}
808+
803809
if (reply.progress.entries > 0) {
804810
reply.term = RAFT_LOG(r, reply.progress.entries - 1).term;
805811
} else {
@@ -875,6 +881,7 @@ static void raft_handle_update(raft_t r, raft_msg_update_t *m) {
875881

876882
reply.success = true;
877883
finish:
884+
assert((reply.progress.entries == m->previndex + 1) || (reply.progress.bytes == 0));
878885
raft_send(r, sender, &reply, sizeof(reply));
879886
}
880887

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/45143b6be4ce1aee9066b1d9be179f39f73b50ec

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy