You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "cecemei (via GitHub)" <gi...@apache.org> on 2026/07/01 19:24:27 UTC
[PR] minor: Add segment debug logging to CachingClusteredClient (druid)
cecemei opened a new pull request, #19648:
URL: https://github.com/apache/druid/pull/19648
### Description
When debugging slow or incorrect queries on the broker, it's useful to know how many segments were found during timeline lookup and how they break down by interval, version, and server type (realtime vs historical).
<hr>
<!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "cecemei (via GitHub)" <gi...@apache.org>.
cecemei commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3508742768
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
+ if (query.context().isDebug()) {
Review Comment:
yes it's only logging in debug setting to avoid verbose, i dont think a query plan has this info? or do you mean defer the logging to sometime later? i think here's better because it's before the caching/pruning stage so we get a whole picture of what segments are included from the timeline
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3510683784
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
Review Comment:
> we also don't have datasegment here, this is really cropped segment descriptor.
The `SegmentDescriptor` is the same as the `SegmentId` minus the datasource.
We already have the datasource name here (`ev.getBaseTableDataSource()`) which is used to extract the timeline in preceding lines.
We should convert all descriptors to `SegmentId` and add a new method `Logger.debugSegmentIds` similar to `Logger.infoSegmentIds`, if needed or we can just use `infoSegmentIds` itself if we are gating this on `query.context().isDebug()`
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19648:
URL: https://github.com/apache/druid/pull/19648#issuecomment-5555848564
This pull request has been marked as stale due to 60 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If you think
that's incorrect or this pull request should instead be reviewed, please simply
write any comment. Even if closed, you can still revive the PR at any time or
discuss it on the dev@druid.apache.org list.
Thank you for your contributions.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3508557703
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
Review Comment:
i think this info bit would be noisy and should be debug too, also maybe consider using `log.debugSegments` for the debug part since it chunks large lists of segments up into smaller log messages
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3520193693
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,20 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ if (query.context().isDebug()) {
+ final String dataSource = ev.getBaseTableDataSource().getName();
+ log.infoSegmentIds(
+ segmentServers.stream().map(
+ s -> SegmentId.of(
+ dataSource,
+ s.getSegmentDescriptor().getInterval(),
Review Comment:
[P2] Log real segment IDs, not query slices
The debug log rebuilds a `SegmentId` from `SegmentDescriptor.getInterval()`, but `computeSegmentsToQuery` fills that descriptor from `TimelineObjectHolder.getInterval()`. `VersionedIntervalTimeline.lookup` trims the first or last holder to the requested interval, so a query over one day inside a week-long segment logs a synthetic segment id that never existed. Use `s.getServer().getSegment().getId()` for the segment id, and log the query interval separately if needed.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3510666997
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
Review Comment:
> we're only logging the total size of segments
Even logging the total segment count per query will become very noisy at high QPS. It is also a little confusing since we don't log any other thing from the lifecycle of a query when `debug` is off.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19648:
URL: https://github.com/apache/druid/pull/19648#issuecomment-5975304577
This pull request/issue has been closed due to lack of activity. If you think that
is incorrect, or the pull request requires review, you can revive the PR at any time.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3508613972
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
+ if (query.context().isDebug()) {
Review Comment:
Since this will happen only when `debug` is set to true in the context, I assume we would do it only in a test environment or while trying to debug a production cluster.
In that case, could a query plan provide this info with the actual segment IDs that would be touched by the query?
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
+ if (query.context().isDebug()) {
+ segmentServers.stream()
+ .collect(Collectors.groupingBy(
+ s -> s.getSegmentDescriptor().getInterval()
+ + "_" + s.getSegmentDescriptor().getVersion()
+ + "_" + (s.getServer() != null && s.getServer().isRealtimeSegment() ? "realtime" : "historical"),
+ Collectors.counting()
Review Comment:
Instead of this, I think we might as well create a `SegmentId` and invoke `.toString()` on it.
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
Review Comment:
+1
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #19648: minor: Add segment debug logging to CachingClusteredClient
URL: https://github.com/apache/druid/pull/19648
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3510683784
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
Review Comment:
> we also don't have datasegment here, this is really cropped segment descriptor.
The `SegmentDescriptor` is the same as the `SegmentId` minus the datasource.
We already have the datasource name here (`ev.getBaseTableDataSource()`) which is used to extract the timeline in preceding lines.
We should convert all descriptors to `SegmentId` and add a new method `Logger.debugSegmentIds` similar to `Logger.infoSegmentIds`.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "cecemei (via GitHub)" <gi...@apache.org>.
cecemei commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3508727540
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
+ if (query.context().isDebug()) {
+ segmentServers.stream()
+ .collect(Collectors.groupingBy(
+ s -> s.getSegmentDescriptor().getInterval()
+ + "_" + s.getSegmentDescriptor().getVersion()
+ + "_" + (s.getServer() != null && s.getServer().isRealtimeSegment() ? "realtime" : "historical"),
+ Collectors.counting()
Review Comment:
this doesn't correspond to a segment, the interval is cropped
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "cecemei (via GitHub)" <gi...@apache.org>.
cecemei commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3508723421
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
Review Comment:
we're only logging the total size of segments not the whole set, we also don't have datasegment here, this is really cropped segment descriptor.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] minor: Add segment debug logging to CachingClusteredClient (druid)
Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis commented on code in PR #19648:
URL: https://github.com/apache/druid/pull/19648#discussion_r3508557703
##########
server/src/main/java/org/apache/druid/client/CachingClusteredClient.java:
##########
@@ -345,6 +345,19 @@ ClusterQueryResult<T> run(
}
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
+ log.info("Query[%s] found [%d] segments from timeline lookup.", query.getId(), segmentServers.size());
Review Comment:
maybe consider using `log.infoSegments` since it chunks large lists of segments up into smaller log messages
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org