akalash commented on a change in pull request #16885:
URL: https://github.com/apache/flink/pull/16885#discussion_r694086768
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java
##########
@@ -760,33 +763,26 @@ private void doRun() {
// make sure the user code classloader is accessible thread-locally
executingThread.setContextClassLoader(userCodeClassLoader.asClassLoader());
- FlinkSecurityManager.monitorUserSystemExitForCurrentThread();
+ TaskInvokable finalInvokable = invokable;
try {
- // Restore invokable data to the last valid state
- invokable.restore();
- } finally {
- FlinkSecurityManager.unmonitorUserSystemExitForCurrentThread();
- }
+ runWithSystemExitMonitoring(finalInvokable::restore);
- if (!transitionState(ExecutionState.INITIALIZING,
ExecutionState.RUNNING)) {
- throw new CancelTaskException();
- }
+ if (!transitionState(ExecutionState.INITIALIZING,
ExecutionState.RUNNING)) {
+ throw new CancelTaskException();
+ }
- // notify everyone that we switched to running
- taskManagerActions.updateTaskExecutionState(
- new TaskExecutionState(executionId,
ExecutionState.RUNNING));
+ // notify everyone that we switched to running
+ taskManagerActions.updateTaskExecutionState(
+ new TaskExecutionState(executionId,
ExecutionState.RUNNING));
- // Monitor user codes from exiting JVM covering user function
invocation. This can be
- // done in a finer-grained way like enclosing user callback
functions individually,
- // but as exit triggered by framework is not performed and
expected in this invoke
- // function anyhow, we can monitor exiting JVM for entire scope.
- FlinkSecurityManager.monitorUserSystemExitForCurrentThread();
- try {
- // run the invokable
- invokable.invoke();
- } finally {
- FlinkSecurityManager.unmonitorUserSystemExitForCurrentThread();
+ runWithSystemExitMonitoring(finalInvokable::invoke);
+ } catch (Throwable throwable) {
+ if (!(throwable instanceof CancelTaskException)) {
Review comment:
as I understand, right now we call `cancelTask` always regardless we
have an exception or not. I am ok with that but I only want to emphasize that
this behavior is different from the old one when `cancelTask` was used only for
an exception case. So if tests are green and nobody sees the problem with that
we can leave it likes that.
--
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]