XComp commented on code in PR #22919:
URL: https://github.com/apache/flink/pull/22919#discussion_r1253186428
##########
flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/DefaultLeaderElectionServiceTest.java:
##########
@@ -125,7 +126,12 @@ void testCloseGrantDeadlock() throws Exception {
final DefaultLeaderElectionService testInstance =
new DefaultLeaderElectionService(
driverFactory,
fatalErrorHandlerExtension.getTestingFatalErrorHandler());
- testInstance.startLeaderElectionBackend();
+
+ // creating the LeaderElection is necessary to instantiate the driver
+ final LeaderElection leaderElection =
testInstance.createLeaderElection("contender-id");
+
leaderElection.startLeaderElection(TestingGenericLeaderContender.newBuilder().build());
+ leaderElection.close();
Review Comment:
> This seems sketchy. Given that the driver is lazily initialized once the
first contender is registered, wouldn't it be intuitive for the driver to be
closed when the last leader election is deregistered?
I thought about that one and it sounds like the more consistent behavior. It
actually works quite well:
* The driver's lifecycle will be bound to the `leaderContenderRegistry` (a
driver is created if a contender is added to the previously empty registry; the
driver is closed if the registry becomes empty again)
* the `leaderOperatiionExecutor` is still bound to the service's lifecycle.
The executor gets added/instantiated within the constructor and shut down in
the service's close method. No new contender can be registered after
`DefaultLeaderElectionService.close` is called
--
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]