leventov commented on a change in pull request #8236: Add TaskResourceCleaner;
fix a couple of concurrency bugs in batch tasks
URL: https://github.com/apache/incubator-druid/pull/8236#discussion_r311237120
##########
File path:
indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java
##########
@@ -146,10 +146,13 @@
private final RetryPolicyFactory retryPolicyFactory;
@JsonIgnore
- private List<IndexTask> indexTaskSpecs;
+ private final AppenderatorsManager appenderatorsManager;
@JsonIgnore
- private AppenderatorsManager appenderatorsManager;
+ private List<IndexTask> indexTaskSpecs;
+
+ @Nullable
+ private volatile IndexTask currentRunningTaskSpec = null;
Review comment:
But first of all, "This variable is updated by the main thread and read by
an HTTP thread when `{@link #stopGracefully}` is called." doesn't explain the
concurrency model in enough detail. Can `{@link #stopGracefully}` be called
fully concurrently at whatever moment in parallel with `runTask()`, or it could
be called only in response to some failure within `runTask()`, just from a
different thread? In the first case, `volatile` is likely needed to ensure
*safe publication* (see JCIP 3.5, or
[here](https://shipilev.net/blog/2014/safe-public-construction/#_safe_publication))
of the `IndexTask` object. In the second case, volatile is almost definitely
redundant, if the thread from which `stopGracefully()` is called "gets
informed" about the failure in `runTask()` in any way that is different from
something like a spin-loop read of a non-volatile field (yes, this is very
obscure and never actually happens in practice).
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]