This is an automated email from the ASF dual-hosted git repository.
gian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new b287b219a8a MSQ: Include stageId, workerNumber in processing thread
names. (#17324)
b287b219a8a is described below
commit b287b219a8a8b928a5b301fbddc954337df6f486
Author: Gian Merlino <[email protected]>
AuthorDate: Fri Oct 11 08:37:15 2024 -0700
MSQ: Include stageId, workerNumber in processing thread names. (#17324)
* MSQ: Include stageId, workerNumber in processing thread names.
Helps identify which query was running in a thread dump.
* s/dart/msq/
---
.../src/main/java/org/apache/druid/msq/exec/WorkerImpl.java | 3 ++-
.../org/apache/druid/frame/processor/FrameProcessorExecutor.java | 9 +++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java
index 46e7e4a1449..6c9f1d89941 100644
---
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java
+++
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/WorkerImpl.java
@@ -969,10 +969,11 @@ public class WorkerImpl implements Worker
/**
* Returns cancellation ID for a particular stage, to be used in {@link
FrameProcessorExecutor#cancel(String)}.
+ * In addition to being a token for cancellation, this also appears in
thread dumps, so make it a little descriptive.
*/
private static String cancellationIdFor(final StageId stageId, final int
workerNumber)
{
- return StringUtils.format("%s_%s", stageId, workerNumber);
+ return StringUtils.format("msq-worker[%s_%s]", stageId, workerNumber);
}
/**
diff --git
a/processing/src/main/java/org/apache/druid/frame/processor/FrameProcessorExecutor.java
b/processing/src/main/java/org/apache/druid/frame/processor/FrameProcessorExecutor.java
index f255fbe13a6..49573b39b4e 100644
---
a/processing/src/main/java/org/apache/druid/frame/processor/FrameProcessorExecutor.java
+++
b/processing/src/main/java/org/apache/druid/frame/processor/FrameProcessorExecutor.java
@@ -222,6 +222,7 @@ public class FrameProcessorExecutor
}
}
+ final String threadName = Thread.currentThread().getName();
boolean canceled = false;
Either<Throwable, ReturnOrAwait<T>> retVal;
@@ -230,6 +231,11 @@ public class FrameProcessorExecutor
throw new InterruptedException();
}
+ if (cancellationId != null) {
+ // Set the thread name to something involving the cancellationId,
to make thread dumps more useful.
+ Thread.currentThread().setName(threadName + "-" + cancellationId);
+ }
+
retVal = Either.value(processor.runIncrementally(readableInputs));
}
catch (Throwable e) {
@@ -253,6 +259,9 @@ public class FrameProcessorExecutor
canceled = true;
}
}
+
+ // Restore original thread name.
+ Thread.currentThread().setName(threadName);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]