You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "JunRuiLee (via GitHub)" <gi...@apache.org> on 2024/10/11 02:26:04 UTC

[PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

JunRuiLee opened a new pull request, #25492:
URL: https://github.com/apache/flink/pull/25492

   
   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph.
   
   
   ## Brief change log
   
   [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph.
   
   ## Verifying this change
   
   This change is already covered by existing tests.
   
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
   


-- 
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-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #25492:
URL: https://github.com/apache/flink/pull/25492#issuecomment-2406433950

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "646c8bba28cffe3531976145efa104f422f33bf4",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "646c8bba28cffe3531976145efa104f422f33bf4",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 646c8bba28cffe3531976145efa104f422f33bf4 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #25492:
URL: https://github.com/apache/flink/pull/25492#discussion_r1797119386


##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/DefaultExecutionPlanStore.java:
##########
@@ -109,153 +110,163 @@ public void stop() throws Exception {
         synchronized (lock) {
             if (running) {
                 running = false;
-                LOG.info("Stopping DefaultJobGraphStore.");
+                LOG.info("Stopping DefaultExecutionPlanStore.");
                 Exception exception = null;
 
                 try {
-                    jobGraphStateHandleStore.releaseAll();
+                    executionPlanStateHandleStore.releaseAll();
                 } catch (Exception e) {
                     exception = e;
                 }
 
                 try {
-                    jobGraphStoreWatcher.stop();
+                    executionPlanStoreWatcher.stop();
                 } catch (Exception e) {
                     exception = ExceptionUtils.firstOrSuppressed(e, exception);
                 }
 
                 if (exception != null) {
                     throw new FlinkException(
-                            "Could not properly stop the DefaultJobGraphStore.", exception);
+                            "Could not properly stop the DefaultExecutionPlanStore.", exception);
                 }
             }
         }
     }
 
     @Nullable
     @Override
-    public JobGraph recoverJobGraph(JobID jobId) throws Exception {
+    public ExecutionPlan recoverExecutionPlan(JobID jobId) throws Exception {
         checkNotNull(jobId, "Job ID");
 
-        LOG.debug("Recovering job graph {} from {}.", jobId, jobGraphStateHandleStore);
+        LOG.debug("Recovering execution plan {} from {}.", jobId, executionPlanStateHandleStore);
 
-        final String name = jobGraphStoreUtil.jobIDToName(jobId);
+        final String name = executionPlanStoreUtil.jobIDToName(jobId);
 
         synchronized (lock) {
             verifyIsRunning();
 
             boolean success = false;
 
-            RetrievableStateHandle<JobGraph> jobGraphRetrievableStateHandle;
+            RetrievableStateHandle<ExecutionPlan> executionPlanRetrievableStateHandle;
 
             try {
                 try {
-                    jobGraphRetrievableStateHandle = jobGraphStateHandleStore.getAndLock(name);
+                    executionPlanRetrievableStateHandle =
+                            executionPlanStateHandleStore.getAndLock(name);
                 } catch (StateHandleStore.NotExistException ignored) {
                     success = true;
                     return null;
                 } catch (Exception e) {
                     throw new FlinkException(
-                            "Could not retrieve the submitted job graph state handle "
+                            "Could not retrieve the submitted execution plan state handle "
                                     + "for "
                                     + name
-                                    + " from the submitted job graph store.",
+                                    + " from the submitted execution plan store.",
                             e);
                 }
 
-                JobGraph jobGraph;
+                ExecutionPlan executionPlan;
                 try {
-                    jobGraph = jobGraphRetrievableStateHandle.retrieveState();
+                    executionPlan = executionPlanRetrievableStateHandle.retrieveState();
                 } catch (ClassNotFoundException cnfe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that you are trying to recover from state written by an "
                                     + "older Flink version which is not compatible. Try cleaning the state handle store.",
                             cnfe);
                 } catch (IOException ioe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that the retrieved state handle is broken. Try cleaning the state handle "
                                     + "store.",
                             ioe);
                 }
 
-                addedJobGraphs.add(jobGraph.getJobID());
+                addedExecutionPlans.add(executionPlan.getJobID());
 
-                LOG.info("Recovered {}.", jobGraph);
+                LOG.info("Recovered {}.", executionPlan);
 
                 success = true;
-                return jobGraph;
+                return executionPlan;
             } finally {
                 if (!success) {
-                    jobGraphStateHandleStore.release(name);
+                    executionPlanStateHandleStore.release(name);
                 }
             }
         }
     }
 
     @Override
-    public void putJobGraph(JobGraph jobGraph) throws Exception {
-        checkNotNull(jobGraph, "Job graph");
+    public void putExecutionPlan(ExecutionPlan executionPlan) throws Exception {
+        checkNotNull(executionPlan, "Execution Plan");
 
-        final JobID jobID = jobGraph.getJobID();
-        final String name = jobGraphStoreUtil.jobIDToName(jobID);
+        final JobID jobID = executionPlan.getJobID();
+        final String name = executionPlanStoreUtil.jobIDToName(jobID);
 
-        LOG.debug("Adding job graph {} to {}.", jobID, jobGraphStateHandleStore);
+        LOG.debug("Adding execution plan {} to {}.", jobID, executionPlanStateHandleStore);
 
         boolean success = false;
 
         while (!success) {
             synchronized (lock) {
                 verifyIsRunning();
 
-                final R currentVersion = jobGraphStateHandleStore.exists(name);
+                final R currentVersion = executionPlanStateHandleStore.exists(name);
 
                 if (!currentVersion.isExisting()) {
                     try {
-                        jobGraphStateHandleStore.addAndLock(name, jobGraph);
+                        executionPlanStateHandleStore.addAndLock(name, executionPlan);
 
-                        addedJobGraphs.add(jobID);
+                        addedExecutionPlans.add(jobID);
 
                         success = true;
                     } catch (StateHandleStore.AlreadyExistException ignored) {
-                        LOG.warn("{} already exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} already exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
-                } else if (addedJobGraphs.contains(jobID)) {
+                } else if (addedExecutionPlans.contains(jobID)) {
                     try {
-                        jobGraphStateHandleStore.replace(name, currentVersion, jobGraph);
-                        LOG.info("Updated {} in {}.", jobGraph, getClass().getSimpleName());
+                        executionPlanStateHandleStore.replace(name, currentVersion, executionPlan);
+                        LOG.info("Updated {} in {}.", executionPlan, getClass().getSimpleName());
 
                         success = true;
                     } catch (StateHandleStore.NotExistException ignored) {
-                        LOG.warn("{} does not exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} does not exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
                 } else {
                     throw new IllegalStateException(
-                            "Trying to update a graph you didn't "
-                                    + "#getAllSubmittedJobGraphs() or #putJobGraph() yourself before.");
+                            "Trying to update a execution plan you didn't "
+                                    + "#getAllSubmittedExecutionPlans() or #putExecutionPlan() yourself before.");
                 }
             }
         }
 
-        LOG.info("Added {} to {}.", jobGraph, jobGraphStateHandleStore);
+        LOG.info("Added {} to {}.", executionPlan, executionPlanStateHandleStore);
     }
 
     @Override
     public void putJobResourceRequirements(
             JobID jobId, JobResourceRequirements jobResourceRequirements) throws Exception {
         synchronized (lock) {
-            @Nullable final JobGraph jobGraph = recoverJobGraph(jobId);
-            if (jobGraph == null) {
+            @Nullable final ExecutionPlan executionPlan = recoverExecutionPlan(jobId);
+            if (executionPlan == null) {
                 throw new NoSuchElementException(
                         String.format(
-                                "JobGraph for job [%s] was not found in JobGraphStore and is needed for attaching JobResourceRequirements.",
+                                "ExecutionPlan for job [%s] was not found in ExecutionPlanStore and is needed for attaching JobResourceRequirements.",
                                 jobId));
             }
-            JobResourceRequirements.writeToJobGraph(jobGraph, jobResourceRequirements);
-            putJobGraph(jobGraph);
+
+            checkState(executionPlan instanceof JobGraph);

Review Comment:
   Seems exceptions will happen if the `StreamGraph` of a streaming job is stored and `updateJobResourceRequirements(...)` is invoked.
   
   Also even if it is a `StreamGraph`, this configuration setting can be applied via `jobConfiguration`?



-- 
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-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee commented on code in PR #25492:
URL: https://github.com/apache/flink/pull/25492#discussion_r1796842931


##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/DefaultExecutionPlanStore.java:
##########
@@ -109,153 +110,163 @@ public void stop() throws Exception {
         synchronized (lock) {
             if (running) {
                 running = false;
-                LOG.info("Stopping DefaultJobGraphStore.");
+                LOG.info("Stopping DefaultExecutionPlanStore.");
                 Exception exception = null;
 
                 try {
-                    jobGraphStateHandleStore.releaseAll();
+                    executionPlanStateHandleStore.releaseAll();
                 } catch (Exception e) {
                     exception = e;
                 }
 
                 try {
-                    jobGraphStoreWatcher.stop();
+                    executionPlanStoreWatcher.stop();
                 } catch (Exception e) {
                     exception = ExceptionUtils.firstOrSuppressed(e, exception);
                 }
 
                 if (exception != null) {
                     throw new FlinkException(
-                            "Could not properly stop the DefaultJobGraphStore.", exception);
+                            "Could not properly stop the DefaultExecutionPlanStore.", exception);
                 }
             }
         }
     }
 
     @Nullable
     @Override
-    public JobGraph recoverJobGraph(JobID jobId) throws Exception {
+    public ExecutionPlan recoverExecutionPlan(JobID jobId) throws Exception {
         checkNotNull(jobId, "Job ID");
 
-        LOG.debug("Recovering job graph {} from {}.", jobId, jobGraphStateHandleStore);
+        LOG.debug("Recovering execution plan {} from {}.", jobId, executionPlanStateHandleStore);
 
-        final String name = jobGraphStoreUtil.jobIDToName(jobId);
+        final String name = executionPlanStoreUtil.jobIDToName(jobId);
 
         synchronized (lock) {
             verifyIsRunning();
 
             boolean success = false;
 
-            RetrievableStateHandle<JobGraph> jobGraphRetrievableStateHandle;
+            RetrievableStateHandle<ExecutionPlan> executionPlanRetrievableStateHandle;
 
             try {
                 try {
-                    jobGraphRetrievableStateHandle = jobGraphStateHandleStore.getAndLock(name);
+                    executionPlanRetrievableStateHandle =
+                            executionPlanStateHandleStore.getAndLock(name);
                 } catch (StateHandleStore.NotExistException ignored) {
                     success = true;
                     return null;
                 } catch (Exception e) {
                     throw new FlinkException(
-                            "Could not retrieve the submitted job graph state handle "
+                            "Could not retrieve the submitted execution plan state handle "
                                     + "for "
                                     + name
-                                    + " from the submitted job graph store.",
+                                    + " from the submitted execution plan store.",
                             e);
                 }
 
-                JobGraph jobGraph;
+                ExecutionPlan executionPlan;
                 try {
-                    jobGraph = jobGraphRetrievableStateHandle.retrieveState();
+                    executionPlan = executionPlanRetrievableStateHandle.retrieveState();
                 } catch (ClassNotFoundException cnfe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that you are trying to recover from state written by an "
                                     + "older Flink version which is not compatible. Try cleaning the state handle store.",
                             cnfe);
                 } catch (IOException ioe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that the retrieved state handle is broken. Try cleaning the state handle "
                                     + "store.",
                             ioe);
                 }
 
-                addedJobGraphs.add(jobGraph.getJobID());
+                addedExecutionPlans.add(executionPlan.getJobID());
 
-                LOG.info("Recovered {}.", jobGraph);
+                LOG.info("Recovered {}.", executionPlan);
 
                 success = true;
-                return jobGraph;
+                return executionPlan;
             } finally {
                 if (!success) {
-                    jobGraphStateHandleStore.release(name);
+                    executionPlanStateHandleStore.release(name);
                 }
             }
         }
     }
 
     @Override
-    public void putJobGraph(JobGraph jobGraph) throws Exception {
-        checkNotNull(jobGraph, "Job graph");
+    public void putExecutionPlan(ExecutionPlan executionPlan) throws Exception {
+        checkNotNull(executionPlan, "Execution Plan");
 
-        final JobID jobID = jobGraph.getJobID();
-        final String name = jobGraphStoreUtil.jobIDToName(jobID);
+        final JobID jobID = executionPlan.getJobID();
+        final String name = executionPlanStoreUtil.jobIDToName(jobID);
 
-        LOG.debug("Adding job graph {} to {}.", jobID, jobGraphStateHandleStore);
+        LOG.debug("Adding execution plan {} to {}.", jobID, executionPlanStateHandleStore);
 
         boolean success = false;
 
         while (!success) {
             synchronized (lock) {
                 verifyIsRunning();
 
-                final R currentVersion = jobGraphStateHandleStore.exists(name);
+                final R currentVersion = executionPlanStateHandleStore.exists(name);
 
                 if (!currentVersion.isExisting()) {
                     try {
-                        jobGraphStateHandleStore.addAndLock(name, jobGraph);
+                        executionPlanStateHandleStore.addAndLock(name, executionPlan);
 
-                        addedJobGraphs.add(jobID);
+                        addedExecutionPlans.add(jobID);
 
                         success = true;
                     } catch (StateHandleStore.AlreadyExistException ignored) {
-                        LOG.warn("{} already exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} already exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
-                } else if (addedJobGraphs.contains(jobID)) {
+                } else if (addedExecutionPlans.contains(jobID)) {
                     try {
-                        jobGraphStateHandleStore.replace(name, currentVersion, jobGraph);
-                        LOG.info("Updated {} in {}.", jobGraph, getClass().getSimpleName());
+                        executionPlanStateHandleStore.replace(name, currentVersion, executionPlan);
+                        LOG.info("Updated {} in {}.", executionPlan, getClass().getSimpleName());
 
                         success = true;
                     } catch (StateHandleStore.NotExistException ignored) {
-                        LOG.warn("{} does not exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} does not exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
                 } else {
                     throw new IllegalStateException(
-                            "Trying to update a graph you didn't "
-                                    + "#getAllSubmittedJobGraphs() or #putJobGraph() yourself before.");
+                            "Trying to update a execution plan you didn't "
+                                    + "#getAllSubmittedExecutionPlans() or #putExecutionPlan() yourself before.");
                 }
             }
         }
 
-        LOG.info("Added {} to {}.", jobGraph, jobGraphStateHandleStore);
+        LOG.info("Added {} to {}.", executionPlan, executionPlanStateHandleStore);
     }
 
     @Override
     public void putJobResourceRequirements(
             JobID jobId, JobResourceRequirements jobResourceRequirements) throws Exception {
         synchronized (lock) {
-            @Nullable final JobGraph jobGraph = recoverJobGraph(jobId);
-            if (jobGraph == null) {
+            @Nullable final ExecutionPlan executionPlan = recoverExecutionPlan(jobId);
+            if (executionPlan == null) {
                 throw new NoSuchElementException(
                         String.format(
-                                "JobGraph for job [%s] was not found in JobGraphStore and is needed for attaching JobResourceRequirements.",
+                                "ExecutionPlan for job [%s] was not found in ExecutionPlanStore and is needed for attaching JobResourceRequirements.",
                                 jobId));
             }
-            JobResourceRequirements.writeToJobGraph(jobGraph, jobResourceRequirements);
-            putJobGraph(jobGraph);
+
+            checkState(executionPlan instanceof JobGraph);

Review Comment:
   Yes, the JobResourceRequirements class is designed specifically for JobGraph



-- 
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-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee commented on code in PR #25492:
URL: https://github.com/apache/flink/pull/25492#discussion_r1797532597


##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/DefaultExecutionPlanStore.java:
##########
@@ -109,153 +110,163 @@ public void stop() throws Exception {
         synchronized (lock) {
             if (running) {
                 running = false;
-                LOG.info("Stopping DefaultJobGraphStore.");
+                LOG.info("Stopping DefaultExecutionPlanStore.");
                 Exception exception = null;
 
                 try {
-                    jobGraphStateHandleStore.releaseAll();
+                    executionPlanStateHandleStore.releaseAll();
                 } catch (Exception e) {
                     exception = e;
                 }
 
                 try {
-                    jobGraphStoreWatcher.stop();
+                    executionPlanStoreWatcher.stop();
                 } catch (Exception e) {
                     exception = ExceptionUtils.firstOrSuppressed(e, exception);
                 }
 
                 if (exception != null) {
                     throw new FlinkException(
-                            "Could not properly stop the DefaultJobGraphStore.", exception);
+                            "Could not properly stop the DefaultExecutionPlanStore.", exception);
                 }
             }
         }
     }
 
     @Nullable
     @Override
-    public JobGraph recoverJobGraph(JobID jobId) throws Exception {
+    public ExecutionPlan recoverExecutionPlan(JobID jobId) throws Exception {
         checkNotNull(jobId, "Job ID");
 
-        LOG.debug("Recovering job graph {} from {}.", jobId, jobGraphStateHandleStore);
+        LOG.debug("Recovering execution plan {} from {}.", jobId, executionPlanStateHandleStore);
 
-        final String name = jobGraphStoreUtil.jobIDToName(jobId);
+        final String name = executionPlanStoreUtil.jobIDToName(jobId);
 
         synchronized (lock) {
             verifyIsRunning();
 
             boolean success = false;
 
-            RetrievableStateHandle<JobGraph> jobGraphRetrievableStateHandle;
+            RetrievableStateHandle<ExecutionPlan> executionPlanRetrievableStateHandle;
 
             try {
                 try {
-                    jobGraphRetrievableStateHandle = jobGraphStateHandleStore.getAndLock(name);
+                    executionPlanRetrievableStateHandle =
+                            executionPlanStateHandleStore.getAndLock(name);
                 } catch (StateHandleStore.NotExistException ignored) {
                     success = true;
                     return null;
                 } catch (Exception e) {
                     throw new FlinkException(
-                            "Could not retrieve the submitted job graph state handle "
+                            "Could not retrieve the submitted execution plan state handle "
                                     + "for "
                                     + name
-                                    + " from the submitted job graph store.",
+                                    + " from the submitted execution plan store.",
                             e);
                 }
 
-                JobGraph jobGraph;
+                ExecutionPlan executionPlan;
                 try {
-                    jobGraph = jobGraphRetrievableStateHandle.retrieveState();
+                    executionPlan = executionPlanRetrievableStateHandle.retrieveState();
                 } catch (ClassNotFoundException cnfe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that you are trying to recover from state written by an "
                                     + "older Flink version which is not compatible. Try cleaning the state handle store.",
                             cnfe);
                 } catch (IOException ioe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that the retrieved state handle is broken. Try cleaning the state handle "
                                     + "store.",
                             ioe);
                 }
 
-                addedJobGraphs.add(jobGraph.getJobID());
+                addedExecutionPlans.add(executionPlan.getJobID());
 
-                LOG.info("Recovered {}.", jobGraph);
+                LOG.info("Recovered {}.", executionPlan);
 
                 success = true;
-                return jobGraph;
+                return executionPlan;
             } finally {
                 if (!success) {
-                    jobGraphStateHandleStore.release(name);
+                    executionPlanStateHandleStore.release(name);
                 }
             }
         }
     }
 
     @Override
-    public void putJobGraph(JobGraph jobGraph) throws Exception {
-        checkNotNull(jobGraph, "Job graph");
+    public void putExecutionPlan(ExecutionPlan executionPlan) throws Exception {
+        checkNotNull(executionPlan, "Execution Plan");
 
-        final JobID jobID = jobGraph.getJobID();
-        final String name = jobGraphStoreUtil.jobIDToName(jobID);
+        final JobID jobID = executionPlan.getJobID();
+        final String name = executionPlanStoreUtil.jobIDToName(jobID);
 
-        LOG.debug("Adding job graph {} to {}.", jobID, jobGraphStateHandleStore);
+        LOG.debug("Adding execution plan {} to {}.", jobID, executionPlanStateHandleStore);
 
         boolean success = false;
 
         while (!success) {
             synchronized (lock) {
                 verifyIsRunning();
 
-                final R currentVersion = jobGraphStateHandleStore.exists(name);
+                final R currentVersion = executionPlanStateHandleStore.exists(name);
 
                 if (!currentVersion.isExisting()) {
                     try {
-                        jobGraphStateHandleStore.addAndLock(name, jobGraph);
+                        executionPlanStateHandleStore.addAndLock(name, executionPlan);
 
-                        addedJobGraphs.add(jobID);
+                        addedExecutionPlans.add(jobID);
 
                         success = true;
                     } catch (StateHandleStore.AlreadyExistException ignored) {
-                        LOG.warn("{} already exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} already exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
-                } else if (addedJobGraphs.contains(jobID)) {
+                } else if (addedExecutionPlans.contains(jobID)) {
                     try {
-                        jobGraphStateHandleStore.replace(name, currentVersion, jobGraph);
-                        LOG.info("Updated {} in {}.", jobGraph, getClass().getSimpleName());
+                        executionPlanStateHandleStore.replace(name, currentVersion, executionPlan);
+                        LOG.info("Updated {} in {}.", executionPlan, getClass().getSimpleName());
 
                         success = true;
                     } catch (StateHandleStore.NotExistException ignored) {
-                        LOG.warn("{} does not exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} does not exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
                 } else {
                     throw new IllegalStateException(
-                            "Trying to update a graph you didn't "
-                                    + "#getAllSubmittedJobGraphs() or #putJobGraph() yourself before.");
+                            "Trying to update a execution plan you didn't "
+                                    + "#getAllSubmittedExecutionPlans() or #putExecutionPlan() yourself before.");
                 }
             }
         }
 
-        LOG.info("Added {} to {}.", jobGraph, jobGraphStateHandleStore);
+        LOG.info("Added {} to {}.", executionPlan, executionPlanStateHandleStore);
     }
 
     @Override
     public void putJobResourceRequirements(
             JobID jobId, JobResourceRequirements jobResourceRequirements) throws Exception {
         synchronized (lock) {
-            @Nullable final JobGraph jobGraph = recoverJobGraph(jobId);
-            if (jobGraph == null) {
+            @Nullable final ExecutionPlan executionPlan = recoverExecutionPlan(jobId);
+            if (executionPlan == null) {
                 throw new NoSuchElementException(
                         String.format(
-                                "JobGraph for job [%s] was not found in JobGraphStore and is needed for attaching JobResourceRequirements.",
+                                "ExecutionPlan for job [%s] was not found in ExecutionPlanStore and is needed for attaching JobResourceRequirements.",
                                 jobId));
             }
-            JobResourceRequirements.writeToJobGraph(jobGraph, jobResourceRequirements);
-            putJobGraph(jobGraph);
+
+            checkState(executionPlan instanceof JobGraph);

Review Comment:
   Yes, you're right. I have corrected it.



-- 
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-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk merged PR #25492:
URL: https://github.com/apache/flink/pull/25492


-- 
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-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #25492:
URL: https://github.com/apache/flink/pull/25492#discussion_r1796834424


##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/DefaultExecutionPlanStore.java:
##########
@@ -109,153 +110,163 @@ public void stop() throws Exception {
         synchronized (lock) {
             if (running) {
                 running = false;
-                LOG.info("Stopping DefaultJobGraphStore.");
+                LOG.info("Stopping DefaultExecutionPlanStore.");
                 Exception exception = null;
 
                 try {
-                    jobGraphStateHandleStore.releaseAll();
+                    executionPlanStateHandleStore.releaseAll();
                 } catch (Exception e) {
                     exception = e;
                 }
 
                 try {
-                    jobGraphStoreWatcher.stop();
+                    executionPlanStoreWatcher.stop();
                 } catch (Exception e) {
                     exception = ExceptionUtils.firstOrSuppressed(e, exception);
                 }
 
                 if (exception != null) {
                     throw new FlinkException(
-                            "Could not properly stop the DefaultJobGraphStore.", exception);
+                            "Could not properly stop the DefaultExecutionPlanStore.", exception);
                 }
             }
         }
     }
 
     @Nullable
     @Override
-    public JobGraph recoverJobGraph(JobID jobId) throws Exception {
+    public ExecutionPlan recoverExecutionPlan(JobID jobId) throws Exception {
         checkNotNull(jobId, "Job ID");
 
-        LOG.debug("Recovering job graph {} from {}.", jobId, jobGraphStateHandleStore);
+        LOG.debug("Recovering execution plan {} from {}.", jobId, executionPlanStateHandleStore);
 
-        final String name = jobGraphStoreUtil.jobIDToName(jobId);
+        final String name = executionPlanStoreUtil.jobIDToName(jobId);
 
         synchronized (lock) {
             verifyIsRunning();
 
             boolean success = false;
 
-            RetrievableStateHandle<JobGraph> jobGraphRetrievableStateHandle;
+            RetrievableStateHandle<ExecutionPlan> executionPlanRetrievableStateHandle;
 
             try {
                 try {
-                    jobGraphRetrievableStateHandle = jobGraphStateHandleStore.getAndLock(name);
+                    executionPlanRetrievableStateHandle =
+                            executionPlanStateHandleStore.getAndLock(name);
                 } catch (StateHandleStore.NotExistException ignored) {
                     success = true;
                     return null;
                 } catch (Exception e) {
                     throw new FlinkException(
-                            "Could not retrieve the submitted job graph state handle "
+                            "Could not retrieve the submitted execution plan state handle "
                                     + "for "
                                     + name
-                                    + " from the submitted job graph store.",
+                                    + " from the submitted execution plan store.",
                             e);
                 }
 
-                JobGraph jobGraph;
+                ExecutionPlan executionPlan;
                 try {
-                    jobGraph = jobGraphRetrievableStateHandle.retrieveState();
+                    executionPlan = executionPlanRetrievableStateHandle.retrieveState();
                 } catch (ClassNotFoundException cnfe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that you are trying to recover from state written by an "
                                     + "older Flink version which is not compatible. Try cleaning the state handle store.",
                             cnfe);
                 } catch (IOException ioe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that the retrieved state handle is broken. Try cleaning the state handle "
                                     + "store.",
                             ioe);
                 }
 
-                addedJobGraphs.add(jobGraph.getJobID());
+                addedExecutionPlans.add(executionPlan.getJobID());
 
-                LOG.info("Recovered {}.", jobGraph);
+                LOG.info("Recovered {}.", executionPlan);
 
                 success = true;
-                return jobGraph;
+                return executionPlan;
             } finally {
                 if (!success) {
-                    jobGraphStateHandleStore.release(name);
+                    executionPlanStateHandleStore.release(name);
                 }
             }
         }
     }
 
     @Override
-    public void putJobGraph(JobGraph jobGraph) throws Exception {
-        checkNotNull(jobGraph, "Job graph");
+    public void putExecutionPlan(ExecutionPlan executionPlan) throws Exception {
+        checkNotNull(executionPlan, "Execution Plan");
 
-        final JobID jobID = jobGraph.getJobID();
-        final String name = jobGraphStoreUtil.jobIDToName(jobID);
+        final JobID jobID = executionPlan.getJobID();
+        final String name = executionPlanStoreUtil.jobIDToName(jobID);
 
-        LOG.debug("Adding job graph {} to {}.", jobID, jobGraphStateHandleStore);
+        LOG.debug("Adding execution plan {} to {}.", jobID, executionPlanStateHandleStore);
 
         boolean success = false;
 
         while (!success) {
             synchronized (lock) {
                 verifyIsRunning();
 
-                final R currentVersion = jobGraphStateHandleStore.exists(name);
+                final R currentVersion = executionPlanStateHandleStore.exists(name);
 
                 if (!currentVersion.isExisting()) {
                     try {
-                        jobGraphStateHandleStore.addAndLock(name, jobGraph);
+                        executionPlanStateHandleStore.addAndLock(name, executionPlan);
 
-                        addedJobGraphs.add(jobID);
+                        addedExecutionPlans.add(jobID);
 
                         success = true;
                     } catch (StateHandleStore.AlreadyExistException ignored) {
-                        LOG.warn("{} already exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} already exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
-                } else if (addedJobGraphs.contains(jobID)) {
+                } else if (addedExecutionPlans.contains(jobID)) {
                     try {
-                        jobGraphStateHandleStore.replace(name, currentVersion, jobGraph);
-                        LOG.info("Updated {} in {}.", jobGraph, getClass().getSimpleName());
+                        executionPlanStateHandleStore.replace(name, currentVersion, executionPlan);
+                        LOG.info("Updated {} in {}.", executionPlan, getClass().getSimpleName());
 
                         success = true;
                     } catch (StateHandleStore.NotExistException ignored) {
-                        LOG.warn("{} does not exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} does not exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
                 } else {
                     throw new IllegalStateException(
-                            "Trying to update a graph you didn't "
-                                    + "#getAllSubmittedJobGraphs() or #putJobGraph() yourself before.");
+                            "Trying to update a execution plan you didn't "

Review Comment:
   a -> an



##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/DefaultExecutionPlanStore.java:
##########
@@ -109,153 +110,163 @@ public void stop() throws Exception {
         synchronized (lock) {
             if (running) {
                 running = false;
-                LOG.info("Stopping DefaultJobGraphStore.");
+                LOG.info("Stopping DefaultExecutionPlanStore.");
                 Exception exception = null;
 
                 try {
-                    jobGraphStateHandleStore.releaseAll();
+                    executionPlanStateHandleStore.releaseAll();
                 } catch (Exception e) {
                     exception = e;
                 }
 
                 try {
-                    jobGraphStoreWatcher.stop();
+                    executionPlanStoreWatcher.stop();
                 } catch (Exception e) {
                     exception = ExceptionUtils.firstOrSuppressed(e, exception);
                 }
 
                 if (exception != null) {
                     throw new FlinkException(
-                            "Could not properly stop the DefaultJobGraphStore.", exception);
+                            "Could not properly stop the DefaultExecutionPlanStore.", exception);
                 }
             }
         }
     }
 
     @Nullable
     @Override
-    public JobGraph recoverJobGraph(JobID jobId) throws Exception {
+    public ExecutionPlan recoverExecutionPlan(JobID jobId) throws Exception {
         checkNotNull(jobId, "Job ID");
 
-        LOG.debug("Recovering job graph {} from {}.", jobId, jobGraphStateHandleStore);
+        LOG.debug("Recovering execution plan {} from {}.", jobId, executionPlanStateHandleStore);
 
-        final String name = jobGraphStoreUtil.jobIDToName(jobId);
+        final String name = executionPlanStoreUtil.jobIDToName(jobId);
 
         synchronized (lock) {
             verifyIsRunning();
 
             boolean success = false;
 
-            RetrievableStateHandle<JobGraph> jobGraphRetrievableStateHandle;
+            RetrievableStateHandle<ExecutionPlan> executionPlanRetrievableStateHandle;
 
             try {
                 try {
-                    jobGraphRetrievableStateHandle = jobGraphStateHandleStore.getAndLock(name);
+                    executionPlanRetrievableStateHandle =
+                            executionPlanStateHandleStore.getAndLock(name);
                 } catch (StateHandleStore.NotExistException ignored) {
                     success = true;
                     return null;
                 } catch (Exception e) {
                     throw new FlinkException(
-                            "Could not retrieve the submitted job graph state handle "
+                            "Could not retrieve the submitted execution plan state handle "
                                     + "for "
                                     + name
-                                    + " from the submitted job graph store.",
+                                    + " from the submitted execution plan store.",
                             e);
                 }
 
-                JobGraph jobGraph;
+                ExecutionPlan executionPlan;
                 try {
-                    jobGraph = jobGraphRetrievableStateHandle.retrieveState();
+                    executionPlan = executionPlanRetrievableStateHandle.retrieveState();
                 } catch (ClassNotFoundException cnfe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that you are trying to recover from state written by an "
                                     + "older Flink version which is not compatible. Try cleaning the state handle store.",
                             cnfe);
                 } catch (IOException ioe) {
                     throw new FlinkException(
-                            "Could not retrieve submitted JobGraph from state handle under "
+                            "Could not retrieve submitted ExecutionPlan from state handle under "
                                     + name
                                     + ". This indicates that the retrieved state handle is broken. Try cleaning the state handle "
                                     + "store.",
                             ioe);
                 }
 
-                addedJobGraphs.add(jobGraph.getJobID());
+                addedExecutionPlans.add(executionPlan.getJobID());
 
-                LOG.info("Recovered {}.", jobGraph);
+                LOG.info("Recovered {}.", executionPlan);
 
                 success = true;
-                return jobGraph;
+                return executionPlan;
             } finally {
                 if (!success) {
-                    jobGraphStateHandleStore.release(name);
+                    executionPlanStateHandleStore.release(name);
                 }
             }
         }
     }
 
     @Override
-    public void putJobGraph(JobGraph jobGraph) throws Exception {
-        checkNotNull(jobGraph, "Job graph");
+    public void putExecutionPlan(ExecutionPlan executionPlan) throws Exception {
+        checkNotNull(executionPlan, "Execution Plan");
 
-        final JobID jobID = jobGraph.getJobID();
-        final String name = jobGraphStoreUtil.jobIDToName(jobID);
+        final JobID jobID = executionPlan.getJobID();
+        final String name = executionPlanStoreUtil.jobIDToName(jobID);
 
-        LOG.debug("Adding job graph {} to {}.", jobID, jobGraphStateHandleStore);
+        LOG.debug("Adding execution plan {} to {}.", jobID, executionPlanStateHandleStore);
 
         boolean success = false;
 
         while (!success) {
             synchronized (lock) {
                 verifyIsRunning();
 
-                final R currentVersion = jobGraphStateHandleStore.exists(name);
+                final R currentVersion = executionPlanStateHandleStore.exists(name);
 
                 if (!currentVersion.isExisting()) {
                     try {
-                        jobGraphStateHandleStore.addAndLock(name, jobGraph);
+                        executionPlanStateHandleStore.addAndLock(name, executionPlan);
 
-                        addedJobGraphs.add(jobID);
+                        addedExecutionPlans.add(jobID);
 
                         success = true;
                     } catch (StateHandleStore.AlreadyExistException ignored) {
-                        LOG.warn("{} already exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} already exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
-                } else if (addedJobGraphs.contains(jobID)) {
+                } else if (addedExecutionPlans.contains(jobID)) {
                     try {
-                        jobGraphStateHandleStore.replace(name, currentVersion, jobGraph);
-                        LOG.info("Updated {} in {}.", jobGraph, getClass().getSimpleName());
+                        executionPlanStateHandleStore.replace(name, currentVersion, executionPlan);
+                        LOG.info("Updated {} in {}.", executionPlan, getClass().getSimpleName());
 
                         success = true;
                     } catch (StateHandleStore.NotExistException ignored) {
-                        LOG.warn("{} does not exists in {}.", jobGraph, jobGraphStateHandleStore);
+                        LOG.warn(
+                                "{} does not exists in {}.",
+                                executionPlan,
+                                executionPlanStateHandleStore);
                     }
                 } else {
                     throw new IllegalStateException(
-                            "Trying to update a graph you didn't "
-                                    + "#getAllSubmittedJobGraphs() or #putJobGraph() yourself before.");
+                            "Trying to update a execution plan you didn't "
+                                    + "#getAllSubmittedExecutionPlans() or #putExecutionPlan() yourself before.");
                 }
             }
         }
 
-        LOG.info("Added {} to {}.", jobGraph, jobGraphStateHandleStore);
+        LOG.info("Added {} to {}.", executionPlan, executionPlanStateHandleStore);
     }
 
     @Override
     public void putJobResourceRequirements(
             JobID jobId, JobResourceRequirements jobResourceRequirements) throws Exception {
         synchronized (lock) {
-            @Nullable final JobGraph jobGraph = recoverJobGraph(jobId);
-            if (jobGraph == null) {
+            @Nullable final ExecutionPlan executionPlan = recoverExecutionPlan(jobId);
+            if (executionPlan == null) {
                 throw new NoSuchElementException(
                         String.format(
-                                "JobGraph for job [%s] was not found in JobGraphStore and is needed for attaching JobResourceRequirements.",
+                                "ExecutionPlan for job [%s] was not found in ExecutionPlanStore and is needed for attaching JobResourceRequirements.",
                                 jobId));
             }
-            JobResourceRequirements.writeToJobGraph(jobGraph, jobResourceRequirements);
-            putJobGraph(jobGraph);
+
+            checkState(executionPlan instanceof JobGraph);

Review Comment:
   Is this method expected to be only invoked on a `JobGraph`?



-- 
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-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-36158][runtime] Refactor Job Recovery Process to Use ExecutionPlan Instead of JobGraph. [flink]

Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee commented on PR #25492:
URL: https://github.com/apache/flink/pull/25492#issuecomment-2407249422

   Thanks @zhuzhurk, I've updated this pr accordingly, PTAL.


-- 
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-unsubscribe@flink.apache.org

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