You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2021/03/19 23:07:02 UTC

[GitHub] [gobblin] sv2000 opened a new pull request #3250: GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation

sv2000 opened a new pull request #3250:
URL: https://github.com/apache/gobblin/pull/3250


   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
   - [x] My PR addresses the following [Gobblin JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
       - https://issues.apache.org/jira/browse/GOBBLIN-1416
   
   
   ### Description
   - [x] Here are some details about my PR, including screenshots (if applicable):
   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
   - [x] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   Added unit test.
   
   ### Commits
   - [x] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
       1. Subject is separated from body by a blank line
       2. Subject is limited to 50 characters
       3. Subject does not end with a period
       4. Subject uses the imperative mood ("add", not "adding")
       5. Body wraps at 72 characters
       6. Body explains "what" and "why", not "how"
   
   


-- 
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:
users@infra.apache.org



[GitHub] [gobblin] autumnust commented on a change in pull request #3250: GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation

Posted by GitBox <gi...@apache.org>.
autumnust commented on a change in pull request #3250:
URL: https://github.com/apache/gobblin/pull/3250#discussion_r598024598



##########
File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/GobblinMultiTaskAttempt.java
##########
@@ -157,6 +161,11 @@ public void run()
     Pair<List<Task>, Boolean> executionResult = runWorkUnits(countDownLatch);
     this.tasks = executionResult.getFirst();
 
+    if (this.tasks.isEmpty() && this.stopped.get()) {

Review 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. 




-- 
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:
users@infra.apache.org



[GitHub] [gobblin] asfgit closed pull request #3250: GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3250:
URL: https://github.com/apache/gobblin/pull/3250


   


-- 
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:
users@infra.apache.org



[GitHub] [gobblin] sv2000 commented on a change in pull request #3250: GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation

Posted by GitBox <gi...@apache.org>.
sv2000 commented on a change in pull request #3250:
URL: https://github.com/apache/gobblin/pull/3250#discussion_r598022064



##########
File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/GobblinMultiTaskAttempt.java
##########
@@ -384,10 +394,14 @@ private boolean taskSuccessfulInPriorAttempt(String taskId) {
    * @return a list of {@link Task}s from the {@link WorkUnit}s, as well as if there's a failure in task creation
    * which should be handled separately to avoid silently starving on certain workunit.
    */
-  private Pair<List<Task>, Boolean> runWorkUnits(CountUpAndDownLatch countDownLatch) {
-
+  private synchronized Pair<List<Task>, Boolean> runWorkUnits(CountUpAndDownLatch countDownLatch) {
     List<Task> tasks = Lists.newArrayList();
-
+    //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()) {

Review 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. 




-- 
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:
users@infra.apache.org



[GitHub] [gobblin] autumnust commented on a change in pull request #3250: GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation

Posted by GitBox <gi...@apache.org>.
autumnust commented on a change in pull request #3250:
URL: https://github.com/apache/gobblin/pull/3250#discussion_r598020976



##########
File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/GobblinMultiTaskAttempt.java
##########
@@ -384,10 +394,14 @@ private boolean taskSuccessfulInPriorAttempt(String taskId) {
    * @return a list of {@link Task}s from the {@link WorkUnit}s, as well as if there's a failure in task creation
    * which should be handled separately to avoid silently starving on certain workunit.
    */
-  private Pair<List<Task>, Boolean> runWorkUnits(CountUpAndDownLatch countDownLatch) {
-
+  private synchronized Pair<List<Task>, Boolean> runWorkUnits(CountUpAndDownLatch countDownLatch) {
     List<Task> tasks = Lists.newArrayList();
-
+    //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()) {

Review comment:
       It doesn't seem to be enough for synchronization purpose. cancel could happen after this line and between line 407 and 408. 




-- 
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:
users@infra.apache.org



[GitHub] [gobblin] sv2000 commented on pull request #3250: GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation

Posted by GitBox <gi...@apache.org>.
sv2000 commented on pull request #3250:
URL: https://github.com/apache/gobblin/pull/3250#issuecomment-803183376


   @autumnust @ZihanLi58 Please review.


-- 
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:
users@infra.apache.org



[GitHub] [gobblin] sv2000 closed pull request #3250: GOBBLIN-1416: Fix a race condition caused by Helix task cancellation being invoked before Gobblin task creation

Posted by GitBox <gi...@apache.org>.
sv2000 closed pull request #3250:
URL: https://github.com/apache/gobblin/pull/3250


   


-- 
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:
users@infra.apache.org