capistrant commented on code in PR #19651:
URL: https://github.com/apache/druid/pull/19651#discussion_r3559586686
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SegmentTransactionalReplaceAction.java:
##########
@@ -169,19 +173,45 @@ private void registerUpgradedPendingSegmentsOnSupervisor(
List<PendingSegmentRecord> upgradedPendingSegments
)
{
+ // Emit one count per upgraded segment (rather than a single aggregate)
regardless of whether a supervisor exists
+ // to receive them, so the total can be compared against the count
actually announced by tasks and so each event
+ // carries the segment's interval and version.
+ for (PendingSegmentRecord upgradedPendingSegment :
upgradedPendingSegments) {
+ final ServiceMetricEvent.Builder metricBuilder = new
ServiceMetricEvent.Builder();
+ IndexTaskUtils.setTaskDimensions(metricBuilder, task);
+ SegmentUpgradeMetrics.setSegmentDimensions(metricBuilder,
upgradedPendingSegment);
+
toolbox.getEmitter().emit(metricBuilder.setMetric(SegmentUpgradeMetrics.COUNT,
1));
+ }
+
final SupervisorManager supervisorManager = toolbox.getSupervisorManager();
final Optional<String> activeSupervisorIdWithAppendLock =
supervisorManager.getActiveSupervisorIdForDatasourceWithAppendLock(task.getDataSource());
if (!activeSupervisorIdWithAppendLock.isPresent()) {
+ log.info("No active streaming supervisor for datasource[%s]; the [%d]
upgraded pending segment(s) from task[%s]"
+ + " will become queryable when their tasks hand off.",
+ task.getDataSource(),
+ upgradedPendingSegments.size(),
+ task.getId()
+ );
return;
}
- upgradedPendingSegments.forEach(
- upgradedPendingSegment ->
supervisorManager.registerUpgradedPendingSegmentOnSupervisor(
- activeSupervisorIdWithAppendLock.get(),
- upgradedPendingSegment
- )
+ // Register each upgraded pending segment on the supervisor and summarize
the whole batch in one log line,
+ // mapping each segment to the number of running tasks the supervisor
notified.
+ final Map<String, Integer> notifiedTasksBySegment = new LinkedHashMap<>();
+ for (PendingSegmentRecord upgradedPendingSegment :
upgradedPendingSegments) {
+ supervisorManager
+
.registerUpgradedPendingSegmentOnSupervisor(activeSupervisorIdWithAppendLock.get(),
upgradedPendingSegment)
+ .ifPresent(notified ->
notifiedTasksBySegment.put(upgradedPendingSegment.getId().toString(),
notified));
+ }
+ log.info(
+ "Registered [%d] upgraded pending segment(s) created by task[%s] on
supervisor[%s]; tasks notified per"
+ + " segment[%s].",
+ notifiedTasksBySegment.size(),
+ task.getId(),
+ activeSupervisorIdWithAppendLock.get(),
+ notifiedTasksBySegment
Review Comment:
fair point
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]