nats-io / nats-server

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

NRG (2.11): Do not revert term on truncate WAL #5975

Closed neilalexander closed 1 month ago

neilalexander commented 1 month ago

It is never safe for the term number to go backwards for any reason, even in a truncate scenario, as this breaks the consistency guarantees and could cause us to vote again in what should be past elections if more than one node has to truncate back at the same time.

All calls to truncateWAL(...) are after the AE has bumped the term number up if needed, so this is safe for making forward progress.

Signed-off-by: Neil Twigg neil@nats.io

neilalexander commented 1 month ago

Force push was to add unit test BTW.

derekcollison commented 1 month ago

ok will wait on green and them merge.