Set thread name when removing tasks
Destroying splits can be expensive and take a long time, so it is
helpful to know the task ID when looking at thread dumps.
@@ -250,6 +250,16 @@ public class TaskExecutor
}
public void removeTask(TaskHandle taskHandle)
+ {
+ try (SetThreadName ignored = new SetThreadName("Task-%s", taskHandle.getTaskId())) {
+ doRemoveTask(taskHandle);
+ }
+
+ // replace blocked splits that were terminated
+ addNewEntrants();
+ }
+
+ private void doRemoveTask(TaskHandle taskHandle)
{
List<PrioritizedSplitRunner> splits;
synchronized (this) {
@@ -273,9 +283,6 @@ public class TaskExecutor
completedTasksPerLevel.incrementAndGet(computeLevel(threadUsageNanos));
log.debug("Task finished or failed " + taskHandle.getTaskId());
-
- // replace blocked splits that were terminated
- addNewEntrants();
}
public List<ListenableFuture<?>> enqueueSplits(TaskHandle taskHandle, boolean intermediate, List<? extends SplitRunner> taskSplits)
