[ 
https://issues.apache.org/jira/browse/GOBBLIN-1078?focusedWorklogId=401789&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-401789
 ]

ASF GitHub Bot logged work on GOBBLIN-1078:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Mar/20 21:22
            Start Date: 11/Mar/20 21:22
    Worklog Time Spent: 10m 
      Work Description: autumnust commented on pull request #2919: 
[GOBBLIN-1078] Coordination between task cancel and initialization in Helix Task
URL: https://github.com/apache/incubator-gobblin/pull/2919#discussion_r391275587
 
 

 ##########
 File path: 
gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTask.java
 ##########
 @@ -95,7 +108,16 @@ public void run()
         .createDefaultTopLevelBroker(jobConfig, 
GobblinScopeTypes.GLOBAL.defaultScopeInstance())) {
       SharedResourcesBroker<GobblinScopeTypes> jobBroker = 
getJobBroker(_jobState, globalBroker);
 
-      _taskAttempt = _taskAttemptBuilder.build(workUnits.iterator(), _jobId, 
_jobState, jobBroker);
+      // Secure atomicity of taskAttempt's execution.
+      // Signaling blocking threads if any whenever taskAttempt is nonNull.
+      _lock.lock();
+      try {
+        _taskAttempt = _taskAttemptBuilder.build(getWorkUnits().iterator(), 
_jobId, _jobState, jobBroker);
+        _taskAttemptBuilt.signal();
+      } finally {
+        _lock.unlock();
+      }
+
       
_taskAttempt.runAndOptionallyCommitTaskAttempt(GobblinMultiTaskAttempt.CommitPolicy.IMMEDIATE);
 
 Review comment:
   I think it is fine, the way that cancel works is, it call `shutdownTasks()` 
which actually sets a flag for each task, indicating the task has been 
terminated externally. This signal will be checked in extractor as it pull data 
from upstream, whenever it is being detected, it accomplish the ongoing loop of 
pulling data.  So the `run()` method within `runAndOptionallyCommitTaskAttempt` 
should still return. 
   
   But I don't have test case to verify this though, I might be too aggressive 
for pruning critical section since it is not performance sensitive at all. Will 
put it back. 
 
----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 401789)
    Time Spent: 1h 20m  (was: 1h 10m)

> Coordination between task cancel and task initialization in Helix
> -----------------------------------------------------------------
>
>                 Key: GOBBLIN-1078
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1078
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Lei Sun
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to