[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342505291
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,11 +417,41 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess) {
+   if (isNotifiable(executionVertexId.get(), 
taskExecutionState)) {
 
 Review comment:
   Just noticed that we are addressing the last comment.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342505291
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,11 +417,41 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess) {
+   if (isNotifiable(executionVertexId.get(), 
taskExecutionState)) {
 
 Review comment:
   Just noticed that you are addressing the last comment.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342504744
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,11 +417,41 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess) {
+   if (isNotifiable(executionVertexId.get(), 
taskExecutionState)) {
 
 Review comment:
   done.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342488581
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,50 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   final Optional 
validTaskExecutionState = getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
}
-   return false;
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
 
 Review comment:
   done.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342488549
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,50 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
 
 Review comment:
   That's right. done.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342488642
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,50 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   final Optional 
validTaskExecutionState = getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
}
-   return false;
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
+
+   // only notifies FINISHED and FAILED states which are needed at 
the moment.
+   // can be refined in FLINK-14233 after the legacy scheduler is 
removed and
+   // the actions are factored out from ExecutionGraph.
+   switch (taskExecutionState.getExecutionState()) {
+   case FINISHED:
+   case FAILED:
+   if (executionVertex.getExecutionState() == 
taskExecutionState.getExecutionState()) {
+   return Optional.of(
+   new TaskExecutionState(
 
 Review comment:
   updated.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342475462
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,50 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   final Optional 
validTaskExecutionState = getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
}
-   return false;
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
+
+   // only notifies FINISHED and FAILED states which are needed at 
the moment.
+   // can be refined in FLINK-14233 after the legacy scheduler is 
removed and
+   // the actions are factored out from ExecutionGraph.
+   switch (taskExecutionState.getExecutionState()) {
+   case FINISHED:
+   case FAILED:
+   if (executionVertex.getExecutionState() == 
taskExecutionState.getExecutionState()) {
+   return Optional.of(
+   new TaskExecutionState(
 
 Review comment:
   Good idea. Will take this change.
   Need to mention that we need to `getExecutionVertexId` before invoking 
`executionGraph.updateState` in case its a terminal state that deregisters the 
execution from execution graph.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-05 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342475462
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,50 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   final Optional 
validTaskExecutionState = getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
}
-   return false;
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
+
+   // only notifies FINISHED and FAILED states which are needed at 
the moment.
+   // can be refined in FLINK-14233 after the legacy scheduler is 
removed and
+   // the actions are factored out from ExecutionGraph.
+   switch (taskExecutionState.getExecutionState()) {
+   case FINISHED:
+   case FAILED:
+   if (executionVertex.getExecutionState() == 
taskExecutionState.getExecutionState()) {
+   return Optional.of(
+   new TaskExecutionState(
 
 Review comment:
   Good idea. Will take this change.
   Need to mention that we need to `getExecutionVertexIdOrThrow` before 
invoking `executionGraph.updateState` in case its a terminal state that 
deregisters the execution from execution graph.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-04 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342386939
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java
 ##
 @@ -1248,21 +1251,9 @@ private void processFail(Throwable t, boolean 
isCallback, Map

[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-04 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342133735
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,55 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   Optional validTaskExecutionState = 
getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
+   }
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
+
+   // check whether this state update is outdated
+   if 
(!currentExecutionAttemptID.equals(taskExecutionState.getID())) {
 
 Review comment:
   done.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-04 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342130601
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,55 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   Optional validTaskExecutionState = 
getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
+   }
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
+
+   // check whether this state update is outdated
+   if 
(!currentExecutionAttemptID.equals(taskExecutionState.getID())) {
 
 Review comment:
   You are right. The resetting will happen async in 
`DefaultScheduler#restartTasksWithDelay`, so that the execution attempt can not 
be outdated here.
   Will remove this check then.


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-04 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342129138
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java
 ##
 @@ -1248,21 +1251,9 @@ private void processFail(Throwable t, boolean 
isCallback, Map

[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-04 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342084999
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,55 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   Optional validTaskExecutionState = 
getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
+   }
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
+
+   // check whether this state update is outdated
+   if 
(!currentExecutionAttemptID.equals(taskExecutionState.getID())) {
+   return Optional.empty();
}
-   return false;
+
+   // only notifies FINISHED and FAILED states which are needed at 
the moment.
+   // can be refined in FLINK-14233 after the legacy scheduler is 
removed and
+   // the actions are factored out from ExecutionGraph.
+   switch (taskExecutionState.getExecutionState()) {
 
 Review comment:
   I think it would be simpler to only consider these two required state 
changes.
   Notifying other states might be no hard but I have not thought it 
thoroughly. Moreover, it's hard to notify all states cleanly at the moment 
before we factored all actions out from ExecutionGraph. So I'd prefer to do it 
in a follow up ticket in Flink 1.11, i.e. FLINK-14233


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


With regards,
Apache Git Services


[GitHub] [flink] zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] Avoid to notify scheduler about fake or outdated state update

2019-11-04 Thread GitBox
zhuzhurk commented on a change in pull request #10067: [FLINK-14375][runtime] 
Avoid to notify scheduler about fake or outdated state update
URL: https://github.com/apache/flink/pull/10067#discussion_r342084999
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/SchedulerBase.java
 ##
 @@ -417,12 +417,55 @@ public void cancel() {
@Override
public final boolean updateTaskExecutionState(final TaskExecutionState 
taskExecutionState) {
final Optional executionVertexId = 
getExecutionVertexId(taskExecutionState.getID());
-   if (executionVertexId.isPresent()) {
-   executionGraph.updateState(taskExecutionState);
-   
updateTaskExecutionStateInternal(executionVertexId.get(), taskExecutionState);
+
+   boolean updateSuccess = 
executionGraph.updateState(taskExecutionState);
+
+   if (updateSuccess && executionVertexId.isPresent()) {
+   Optional validTaskExecutionState = 
getValidTaskExecutionState(
+   executionVertexId.get(),
+   taskExecutionState);
+
+   if (validTaskExecutionState.isPresent()) {
+   
updateTaskExecutionStateInternal(executionVertexId.get(), 
validTaskExecutionState.get());
+   }
return true;
+   } else {
+   return false;
+   }
+   }
+
+   private Optional getValidTaskExecutionState(
+   final ExecutionVertexID executionVertexId,
+   final TaskExecutionState taskExecutionState) {
+
+   final ExecutionVertex executionVertex = 
getExecutionVertex(executionVertexId);
+   final ExecutionAttemptID currentExecutionAttemptID = 
executionVertex.getCurrentExecutionAttempt().getAttemptId();
+
+   // check whether this state update is outdated
+   if 
(!currentExecutionAttemptID.equals(taskExecutionState.getID())) {
+   return Optional.empty();
}
-   return false;
+
+   // only notifies FINISHED and FAILED states which are needed at 
the moment.
+   // can be refined in FLINK-14233 after the legacy scheduler is 
removed and
+   // the actions are factored out from ExecutionGraph.
+   switch (taskExecutionState.getExecutionState()) {
 
 Review comment:
   I think it would be simpler to only consider these two required state 
changes.
   Notifying other states might be no harm but I have not thought it 
thoroughly. Moreover, it's hard to notify all states cleanly at the moment 
before we factored all actions out from ExecutionGraph. So I'd prefer to do it 
in a follow up ticket in Flink 1.11, i.e. FLINK-14233


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


With regards,
Apache Git Services