ZihanLi58 commented on a change in pull request #2919: [GOBBLIN-1078] 
Coordination between task cancel and initialization in Helix Task
URL: https://github.com/apache/incubator-gobblin/pull/2919#discussion_r391159295
 
 

 ##########
 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:
   why do we move this out of the lock? What will happen if _taskAttemp is 
initiated but not run, and cancel happen and then call 
_taskAttempt.runAndOptionallyCommitTaskAttempt() 

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to