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_r395222680
########## File path: gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTask.java ########## @@ -93,8 +109,17 @@ public void run() .createDefaultTopLevelBroker(jobConfig, GobblinScopeTypes.GLOBAL.defaultScopeInstance())) { SharedResourcesBroker<GobblinScopeTypes> jobBroker = getJobBroker(_jobState, globalBroker); - _taskAttempt = _taskAttemptBuilder.build(workUnits.iterator(), _jobId, _jobState, jobBroker); - _taskAttempt.runAndOptionallyCommitTaskAttempt(GobblinMultiTaskAttempt.CommitPolicy.IMMEDIATE); + // Secure atomicity of taskAttempt's execution. + // Signaling blocking threads if any whenever taskAttempt is nonNull. + _taskAttempt = _taskAttemptBuilder.build(getWorkUnits().iterator(), _jobId, _jobState, jobBroker); + + _lock.lock(); + try { + _taskAttemptBuilt.signal(); + _taskAttempt.runAndOptionallyCommitTaskAttempt(GobblinMultiTaskAttempt.CommitPolicy.IMMEDIATE); Review comment: I was mistakenly thinking runAndOptionallyCommitTaskAttempt will return immediately. Then how about move this method out and make the build of taskAttemp inside the lock block? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services