[SERVER-19704] Store the current term in persistent storage Created: 31/Jul/15  Updated: 05/Aug/15  Resolved: 03/Aug/15

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Siyuan Zhou Assignee: Siyuan Zhou
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-19738 Restore current term at startup Closed
Sprint: RPL 7 08/10/15
Participants:

 Description   

New election protocol requires storing the current term (latest term server has seen) and the voted candidate id when updating the term. We'll use candidate index to avoid negative _id. Thus, candidate index == -1 means we haven't voted for the current term.



 Comments   
Comment by Siyuan Zhou [ 03/Aug/15 ]

milkie, SERVER-19738 has been filed to track the new design. Shall I close this one?

Comment by Siyuan Zhou [ 03/Aug/15 ]

Discussed with Eric in person, we think it's OK to restore the startup term from the last entry in oplog and the last vote document, whichever is greater. Thus we can save a database write whenever a secondary learns a new term.

The term in the last oplog entry guarantees that the terms in oplog never go backwards. The last vote's term guarantees that a stale primary won't commit an operation on the majority once a new primary wins an election, even if some nodes (including voters of the new primary) restart at the meantime. Terms on the minority secondaries that didn't participate the last vote may go backwards for a short time after a restart, but it should be harmless.

schwerin, I used to plan to change LastVote to ElectionState, which is the last vote if the node participated the latest vote, or the latest term with an empty candidate if it learned the term from others, meaning it hasn't voted anyone for that term.

Comment by Eric Milkie [ 02/Aug/15 ]

I needed the weekend to think about this. I think this is not necessary to do. instead, the election no-op 'n' op will dictate the correct term to start in, if there aren't any other ops in the current term.
This came up for one-node replica sets that go right to state Primary, it wasn't choosing the correct startup term.

Comment by Andy Schwerin [ 02/Aug/15 ]

Where will the information be stored?

Generated at Thu Feb 08 03:51:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.