...
Note that only voters receive the BeginQuorumEpoch
request: observers will discover the new leader through either the FindQuorum
or FetchQuorumRecords
APIs. For example, the old leader would return an error code in FetchQuorumRecords
response indicating that it is no longer the leader and it will also encode the current known leader id / epoch as well, then the observers can start fetching from the new leader. In case the old leader does not know who's the new leader, observers can still fallback to FindQuorum
request to discover the new leader.
TODO: If we piggyback the leader ID on some of the APIs, we may need to add connection information as well. Otherwise, if the hostname changes after a restart, a voter may be stuck with stale information.
Request Schema
Code Block |
---|
{ "apiKey": N, "type": "request", "name": "BeginQuorumEpochRequest", "validVersions": "0", "fields": [ {"name": "ClusterId", "type": "string", "versions": "0+"}, {"name": "LeaderId", "type": "int32", "versions": "0+", "about": "The ID of the newly elected leader"}, {"name": "LeaderEpoch", "type": "int32", "versions": "0+", "about": "The epoch of the newly elected leader"} ] } |
...
The FindQuorum
API also provides the crucial role of discovering connection information for existing nodes using a gossip approach. Brokers include their own connection information in the request and collect the connection information of the voters in the cluster from the response. Additionally, if one of the voters becomes unreachable at some point, then FindQuorum
can be used to find the new connection information (similar to how metadata refreshes are used in the client after a disconnect).
Request Schema
Code Block |
---|
{ "apiKey": N, "type": "request", "name": "FindQuorumRequest", "validVersions": "0", "flexibleVersions": "0+", "fields": [ { "name": "ReplicaId", "type": "int32", "versions": "0+"}, { "name": "BootTimestamp", "type": "int64", "versions": "0+"}, { "name": "Host", "type": "string", "versions": "0+"}, { "name": "Port", "type": "int32", "versions": "0+"}, { "name": "SecurityProtocol", "type": "int16", "versions": "0+"} ] } |
...