[SERVER-34682] Old primary should vote yes and store the last vote after stepdown on learning of a higher term Created: 26/Apr/18  Updated: 29/Oct/23  Resolved: 16/May/18

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 3.4.17, 3.6.6, 4.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Siyuan Zhou Assignee: William Schultz (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
is caused by SERVER-27534 All writing operations must fail if t... Closed
Related
related to SERVER-35766 Replication commands sent in candidat... Closed
related to SERVER-47612 Elections not robust in remove_newly_... Closed
is related to SERVER-34661 Return early when the vote request re... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6, v3.4
Sprint: Repl 2018-05-21
Participants:
Linked BF Score: 17

 Description   

After stepdown, the old primary should store the last vote successfully even if the operation has been killed due to InterruptedDueToReplStateChange. The response should return

{ ok: 1 }

.



 Comments   
Comment by Githook User [ 24/Jul/18 ]

Author:

{'username': 'will62794', 'name': 'William Schultz', 'email': 'william.schultz@mongodb.com'}

Message: SERVER-34682 Assert that replSetRequestVotes response status is OK
Branch: v3.4
https://github.com/mongodb/mongo/commit/bce06a11d01ad73da232934957e34cd0a2b9ca21

Comment by Githook User [ 19/Jun/18 ]

Author:

{'username': 'will62794', 'name': 'William Schultz', 'email': 'william.schultz@mongodb.com'}

Message: SERVER-34682 Assert that replSetRequestVotes response status is OK
Branch: v3.6
https://github.com/mongodb/mongo/commit/6ce607a20faba65544f4eaf5d347339816b73e6b

Comment by William Schultz (Inactive) [ 11/Jun/18 ]

Yep, that sounds appropriate to me.

Comment by Siyuan Zhou [ 17/May/18 ]

william.schultz, I think this second part of your patch (asserting that the vote response is actually
ok) needs to backport to 3.6 and maybe 3.4. What do you think?

Comment by Githook User [ 16/May/18 ]

Author:

{'email': 'william.schultz@mongodb.com', 'username': 'will62794', 'name': 'William Schultz'}

Message: SERVER-34682 Old primary should be able to store last vote when casting vote in new term

This patch allows a current primary to step down and cast its vote for a
new primary in a higher term in one step. This allows for a new
candidate to become elected faster if it relies on the vote of an old
primary. Previously, when learning of a higher term via a
replSetRequestVote request, a primary would step down, causing us to
interrupt the processing of the vote request when we try to acquire a
lock to write down our LastVote document with an
InterruptedDueToReplStateChange code. This patch allows us to ignore
these interrupts, so we can proceed with processing the vote request.

Additionally, this patch also asserts that the vote response is actually
ok, so that we don't erroneously send a voteGranted=yes response even if
we failed to persist our last vote document.
Branch: master
https://github.com/mongodb/mongo/commit/6ccdeffc5aa60822d352ac389cb9e8e5647c242d

Comment by William Schultz (Inactive) [ 10/May/18 ]

To clarify, the issue is that we populate the response to a replSetRequestVote command here, then write down our vote to the LastVote document. The DB lock acquisition inside storeLocalLastVoteDocument method may get interrupted with InterruptedDueToReplStateChange, if we are currently in the process of stepping down. This will cause us to return a bad status from processReplSetRequestVotes, but the response will be populated as if we granted our vote. This will cause us to end up sending a response that contains an ok: 0 field but with a body that indicates we granted a "yes" vote i.e. voteGranted=true.

Comment by Siyuan Zhou [ 28/Apr/18 ]

We want the new primary to get a vote from the old primary, so 2-node replset can finish an election quickly. The old primary steps down on receiving the higher term from the new one.

Comment by Spencer Brody (Inactive) [ 27/Apr/18 ]

Why are you voting as part of stepping down?

Generated at Thu Feb 08 04:37:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.