XComp commented on code in PR #21742:
URL: https://github.com/apache/flink/pull/21742#discussion_r1163923621
##########
flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/DefaultLeaderElectionService.java:
##########
@@ -205,20 +208,7 @@ public void onGrantLeadership(UUID newLeaderSessionId) {
public void onRevokeLeadership() {
synchronized (lock) {
if (running) {
- LOG.debug(
- "Revoke leadership of {} ({}@{}).",
- leaderContender.getDescription(),
- confirmedLeaderInformation.getLeaderSessionID(),
- confirmedLeaderInformation.getLeaderAddress());
-
- issuedLeaderSessionID = null;
- clearConfirmedLeaderInformation();
-
- leaderContender.revokeLeadership();
-
- LOG.debug("Clearing the leader information on {}.",
leaderElectionDriver);
- // Clear the old leader information on the external storage
-
leaderElectionDriver.writeLeaderInformation(LeaderInformation.empty());
Review Comment:
`onRevokeLeadership()` is called _after_ the leadership is lost. All
`LeaderElectionDriver` implementations do a check before writing data to the
backend which prevents any writes if the leadership is lost:
*
[ZooKeeperLeaderElectionDriver:198](https://github.com/apache/flink/blob/d76214de330fea485f2971b51c172420dfdf500b/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderElectionDriver.java#L198)
(but we even ignore empty leader information in
[ZooKeeperLeaderElectionDriver:190](https://github.com/apache/flink/blob/d76214de330fea485f2971b51c172420dfdf500b/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderElectionDriver.java#L190)).
Same code is available for the
[ZooKeeperMultipleComponentLeaderElectionDriver.java:154](https://github.com/apache/flink/blob/8ddfd590ebba7fc727e79db41b82d3d40a02b56a/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperMultipleComponentLeaderElectionDriver.java#L154)
*
[KubernetesLeaderElectionDriver:139](https://github.com/apache/flink/blob/bba7c417217be878fffb12efedeac50dec2a7459/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/highavailability/KubernetesLeaderElectionDriver.java#L139)
*
[KubernetesMultipleComponentLeaderElectionDriver:169](https://github.com/apache/flink/blob/0290715a57b8d243586ab747b0cd2416c8081012/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/highavailability/KubernetesMultipleComponentLeaderElectionDriver.java#L169)
One could argue that the leadership could be regained while the operation
isn't omitted, yet. Then, we would miss writing the empty leader information.
But in that case, leadership will be renegotiated anyway which will trigger a
write operation with the updated leader information soon after.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]