NRG (2.11): Fix term handling in candidate state and use higher term from vote request #5671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A candidate could incorrectly revert to an older term without resetting if an old AE arrived with a term that is at least newer than the pterm but not necessarily newer than the term.
Additionally, we also weren't handling the case that the rest of the cluster should assume the higher term number from the vote requests once an isolated candidate node rejoins the cluster.
This PR also rewrites
TestNRGCandidateStepsDownAfterAE
and replaces it withTestNRGAssumeHighTermAfterCandidateIsolation
as the old test was checking for flawed behaviour: it was relying on the term being able to go backwards after a period of isolation, which is not correct. Instead we should prove that the rest of the cluster assumes the higher term from the isolated node.Co-authored-by: Reuben Ninan reuben@nats.io
Signed-off-by: Neil Twigg neil@nats.io