xintongsong commented on a change in pull request #14485:
URL: https://github.com/apache/flink/pull/14485#discussion_r549318707



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerImpl.java
##########
@@ -268,21 +276,27 @@ private void unregisterJobFromHighAvailability() {
 
        @Override
        public void grantLeadership(final UUID leaderSessionID) {
-               synchronized (lock) {
-                       if (shutdown) {
-                               log.debug("JobManagerRunner cannot be granted 
leadership because it is already shut down.");
-                               return;
-                       }
-
-                       leadershipOperation = leadershipOperation.thenCompose(
-                               (ignored) -> {
-                                       synchronized (lock) {
-                                               return 
verifyJobSchedulingStatusAndStartJobManager(leaderSessionID);
+               jobMasterCreationFuture.whenComplete(

Review comment:
       It is possible that the `LeaderElectionService` call `grantLeadership` 
on the same thread that `LeaderElectionService#start` is called (e.g., 
`StandaloneLeaderElectionService` & `TestingLeaderElectionService`). In that 
case, the lock does not block the thread from entering `grantLeadership` when 
`JobManagerRunnerImpl` has not been properly initialized.
   
   Please see this comment:
   https://github.com/apache/flink/pull/14485#discussion_r548399979




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to