autumnust 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_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]
With regards,
Apache Git Services