WencongLiu commented on code in PR #22341: URL: https://github.com/apache/flink/pull/22341#discussion_r1295337613
########## flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterServiceLeadershipRunner.java: ########## @@ -488,18 +523,21 @@ private boolean isRunning() { return state == State.RUNNING; } - private void runIfValidLeader( - UUID expectedLeaderId, Runnable action, String actionDescription) { + private <T> CompletableFuture<T> runIfValidLeader( Review Comment: I've added these two methods. ########## flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterServiceLeadershipRunner.java: ########## @@ -261,34 +261,69 @@ 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); + } + if (isValid) { + sequentialOperation = + sequentialOperation.thenCompose( + unused -> + runIfValidLeader( + leaderSessionId, + () -> + jobResultStore.hasJobResultEntryAsync( + getJobID()), + "verify jbb result entry") + .handle( Review Comment: Fixed. ########## flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterServiceLeadershipRunner.java: ########## @@ -261,34 +261,69 @@ 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); + } + if (isValid) { + sequentialOperation = + sequentialOperation.thenCompose( + unused -> + runIfValidLeader( + leaderSessionId, + () -> + jobResultStore.hasJobResultEntryAsync( + getJobID()), + "verify jbb result entry") Review Comment: Sorry for the mistake. Fixed. ########## flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterServiceLeadershipRunner.java: ########## @@ -261,34 +261,69 @@ 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); + } + if (isValid) { + sequentialOperation = + sequentialOperation.thenCompose( + unused -> + runIfValidLeader( + leaderSessionId, + () -> + jobResultStore.hasJobResultEntryAsync( + getJobID()), + "verify jbb result entry") + .handle( + (hasJobResult, throwable) -> { + if (hasJobResult == null) { Review Comment: Currently the `throwable` is handled. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org