Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

{
"apiKey": 52,
"type": "response",
"name": "VoteResponse",
"validVersions": "0-1",
"flexibleVersions": "0+",
"fields": [
{ "name": "ErrorCode", "type": "int16", "versions": "0+",
"about": "The top level error code."},
{ "name": "Topics", "type": "[]TopicData",
"versions": "0+", "fields": [
{ "name": "TopicName", "type": "string", "versions": "0+", "entityType": "topicName",
"about": "The topic name." },
{ "name": "Partitions", "type": "[]PartitionData",
"versions": "0+", "fields": [
{ "name": "PartitionIndex", "type": "int32", "versions": "0+",
"about": "The partition index." },
{ "name": "ErrorCode", "type": "int16", "versions": "0+"},
{ "name": "LeaderId", "type": "int32", "versions": "0+", "entityType": "brokerId",
"about": "The ID of the current leader or -1 if the leader is unknown."},
{ "name": "LeaderEpoch", "type": "int32", "versions": "0+",
"about": "The latest known leader epoch"},
{ "name": "VoteGranted", "type": "bool", "versions": "0+",
"about": "True if the vote was granted and false otherwise"},
       { "name": "PreVote", "type": "boolean", "versions": "1+",
"about": "Whether the response is a PreVote response or not."}

...
}

...

Proposed Changes


Section
bordertrue

We add a new state Prospective for servers which are sending Pre-Vote requests as well as new state transitions

...

. The original (left) and new states (right) are below for comparison.

Column
width50%
 
Code Block
* Unattached|Resigned transitions to:

 *  
Unattached
 Unattached: After learning of a new election with a higher epoch
-

 *  
Voted
 Voted: After granting a vote to a candidate
+

 *    Candidate: After expiration of the election timeout
 *    Follower: After discovering a leader with an equal or larger epoch
 *
 * Voted transitions to:
 *    Unattached: After learning of a new election with a higher epoch
 *    Candidate: After expiration of the election timeout
 *
 * Candidate transitions to:
 *    Unattached: After learning of a new election with a higher epoch
 *    Candidate: After expiration of the election timeout
 *    Leader: After receiving a majority of votes
 *
 * Leader transitions to:
 *    Unattached: After learning of a new election with a higher epoch
 *    Resigned: When shutting down gracefully
 *
 * Follower transitions to:
 *    Unattached: After learning of a new election with a higher epoch
 *    Candidate: After expiration of the fetch timeout
*    Follower: After discovering a leader with a larger epoch


Column
width50%
 * Unattached|Resigned transitions to:
 *    Unattached: After learning of a candidate with a higher epoch (clarifying language)
 *    Voted: After granting a standard vote to a candidate
-
 
* Candidate: After expiration of the election timeout +
(clarifying language)
 *    Prospective: After expiration of the election timeout
 *    Follower: After discovering a leader with an equal or larger epoch
 *
 * Voted transitions to:

*    Unattached: After learning of a 
new election
candidate with a higher epoch
- * Candidate: After expiration of the election
 
timeout

+
 *    Prospective: After expiration of the election timeout
+
 *    Follower: After discovering a leader with an equal or larger epoch (
already a valid transition, just
missed in original docs)   
+
 *
+
 * Prospective transitions to:
+
 
* Unattached: After learning of a
new election
candidate with a higher epoch
+
   
* Candidate: After receiving a majority of pre-votes
+
 *    Follower: After discovering a leader with an equal or larger epoch
*
 
* Candidate transitions to:
    
* Unattached: After learning of a
new
candidate 
election
with a higher epoch
- * Candidate: After expiration of the election timeout + * Prospective:
 
After
 
expiration of the election
 
timeout

-
 *    
Leader
Prospective: After 
receiving
expiration 
a
of 
majority
the 
of
election 
votes
timeout
+
 *    Leader: After receiving a majority of standard votes
+
 *    Follower: After discovering a leader with an equal or larger epoch (
already a valid transition, just
missed in original docs)
 *
 
* Leader transitions to:

*    Unattached: After learning of a 
new election
candidate with a higher epoch
 
*  
 * Follower transitions to:

* Unattached: After learning of a
new
candidate 
election
with a higher epoch
- * Candidate: After expiration
 
of
 
the fetch timeout

+
 *    Prospective: After expiration of the election timeout
 *    Follower: After discovering a leader with a larger epoch


A candidate will now send a VoteRequest with the PreVote field set to true and CandidateEpoch set to its [epoch + 1] when its election timeout expires. If [majority - 1] of VoteResponse grant the vote, the candidate will then bump its epoch up and send a VoteRequest with PreVote set to false which is our standard vote that will cause state changes for servers receiving the request.

...