nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
16k stars 1.41k forks source link

NRG: Don't switch to candidate when waiting for pending applies #6056

Closed MauriceVanVeen closed 3 weeks ago

MauriceVanVeen commented 3 weeks ago

A follower could become candidate/leader before processing a snapshot. Based on timing the snapshot could enter into the apply queue, and before n.PauseApply() is called the follower could freely become leader and then fail processing the snapshot.

When a snapshot is not successfully applied yet, block the follower from becoming candidate until the snapshot is processed.

Signed-off-by: Maurice van Veen github@mauricevanveen.com

derekcollison commented 3 weeks ago

Let me know when ready for review.

neilalexander commented 3 weeks ago

Maurice and I have been on Zoom talking about this change and we've come up with a cleaner fix, so will be posting an update soon. Will let you know when ready for review.

neilalexander commented 3 weeks ago

@derekcollison This one is ready for review now!