XComp commented on code in PR #22341:
URL: https://github.com/apache/flink/pull/22341#discussion_r1290977544


##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterServiceLeadershipRunner.java:
##########
@@ -261,17 +260,34 @@ public void grantLeadership(UUID leaderSessionID) {
 
     @GuardedBy("lock")
     private void startJobMasterServiceProcessAsync(UUID leaderSessionId) {
-        sequentialOperation =
-                sequentialOperation.thenRun(
-                        () ->
-                                runIfValidLeader(
-                                        leaderSessionId,
-                                        ThrowingRunnable.unchecked(
-                                                () ->
-                                                        
verifyJobSchedulingStatusAndCreateJobMasterServiceProcess(
-                                                                
leaderSessionId)),
-                                        "verify job scheduling status and 
create JobMasterServiceProcess"));
-
+        boolean isValid;
+        synchronized (lock) {
+            isValid = isValidLeader(leaderSessionId);

Review Comment:
   We still need to use the `runIfValidLeader`. But we need to adapt it in a 
way that we also allow the returning of a value (for the 
`hasJobResultEntryAsync` return).



##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterServiceLeadershipRunner.java:
##########
@@ -261,17 +260,34 @@ public void grantLeadership(UUID leaderSessionID) {
 
     @GuardedBy("lock")
     private void startJobMasterServiceProcessAsync(UUID leaderSessionId) {
-        sequentialOperation =
-                sequentialOperation.thenRun(
-                        () ->
-                                runIfValidLeader(
-                                        leaderSessionId,
-                                        ThrowingRunnable.unchecked(
-                                                () ->
-                                                        
verifyJobSchedulingStatusAndCreateJobMasterServiceProcess(
-                                                                
leaderSessionId)),
-                                        "verify job scheduling status and 
create JobMasterServiceProcess"));
-
+        boolean isValid;
+        synchronized (lock) {
+            isValid = isValidLeader(leaderSessionId);

Review Comment:
   That goes into the right direction. :+1:  The leader validity should be 
checked when calling the methods (i.e. when checking the `jobResultStore` in 
the `thenCompose` and the handling of the response in the `handle` method).



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

Reply via email to