GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation#3250
GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation#3250sv2000 wants to merge 2 commits intoapache:masterfrom
Conversation
…being invoked before Gobblin task creation
|
@autumnust @ZihanLi58 Please review. |
| //Has the task-attempt already been cancelled? This can happen for instance when a cancellation has been invoked on | ||
| // the GobblinMultiTaskAttempt instance (e.g. in the case of Helix task cancellation) before the Gobblin tasks | ||
| // have been submitted to the underlying task executor. | ||
| if (this.stopped.get()) { |
There was a problem hiding this comment.
It doesn't seem to be enough for synchronization purpose. cancel could happen after this line and between line 407 and 408.
There was a problem hiding this comment.
Note that shutdownTasks() is synchronized too. So if cancel has not been called yet (i.e. at line 402), the task creation is guaranteed to be completed and tasks will be submitted to the executor, before shutdownTasks() gets called.
| Pair<List<Task>, Boolean> executionResult = runWorkUnits(countDownLatch); | ||
| this.tasks = executionResult.getFirst(); | ||
|
|
||
| if (this.tasks.isEmpty() && this.stopped.get()) { |
There was a problem hiding this comment.
Let me know if this understanding is correct: whenever these two conditions hold at the same time, it indicates that the cancel happens before the task is materialized and executed in the executor. ( since the regular cancel will result in tasks being non empty). Can you add a comment if this is the case, just to distinguish between the regular cancel.
… being invoked before Gobblin task creation Closes apache#3250 from sv2000/taskCancelRaceCondition
Dear Gobblin maintainers,
Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
JIRA
Description
Invocation of Gobblin Helix task cancellation before underlying Gobblin tasks have been created or submitted to the task executor results in GobblinHelixTask#cancel() returning successfully, but without preventing future submission of Gobblin tasks to the executor.
Tests
Added unit test.
Commits