XComp commented on code in PR #22384:
URL: https://github.com/apache/flink/pull/22384#discussion_r1200614397
##########
flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingContender.java:
##########
@@ -41,13 +42,20 @@ public TestingContender(
this.leaderElectionService = leaderElectionService;
}
+ public LeaderElection startLeaderElection() throws Exception {
+ leaderElection = leaderElectionService.createLeaderElection();
Review Comment:
`LeaderElection.startLeaderElection` needs to be called outside of the
contender's constructor for now. The reason for this is that we have this
cyclic dependency between `DefaultLeaderElectionService` and the
`MultipleComponentLeaderElectionDriverAdapter`. Registering a contender in the
`MultipleComponentLeaderElectionService` through the adapter might result in an
immediate leadership grant to the contender if the leadership was acquired
beforehand. Calling `startLeaderElection` from within the constructor with
`this` (the contender) as a parameter would result in the grant call being
triggered on a not-fully-initialized instance.
It's essentially the same reason why we cannot move
`DefaultLeaderElectionService#startLeaderElectionBackend()` into the
`DefaultLeaderElectionService` constructor. We can do this after all the other
refactoring is done.
--
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]