kfaraz commented on code in PR #19679:
URL: https://github.com/apache/druid/pull/19679#discussion_r3572370218
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SegmentTransactionalReplaceAction.java:
##########
@@ -209,49 +212,46 @@ void registerUpgradedPendingSegmentsOnSupervisor(
return;
}
- // Register each upgraded pending segment on the supervisor and summarize
the batch. The per-segment mapping is
- // unbounded (a broad REPLACE can upgrade thousands of segments), so INFO
carries aggregate counts plus a bounded
- // sample and the full mapping is materialized only when DEBUG is enabled.
- final boolean debugEnabled = log.isDebugEnabled();
- final Map<String, Integer> notifiedTasksSample = new LinkedHashMap<>();
- final Map<String, Integer> notifiedTasksBySegment = debugEnabled ? new
LinkedHashMap<>() : null;
+ // Try to register the upgraded pending segments with all eligible
supervisors
+ // Only the supervisor which owns a pending segment will actually register
it
+ for (String supervisorId : activeSupervisorIdWithAppendLock) {
+ registerUpgradedPendingSegmentOnSupervisor(task, toolbox,
upgradedPendingSegments, supervisorId);
+ }
+ }
+
+ /**
+ * Registers each upgraded pending segment on the given supervisor and prints
+ * a summary of the batch.
+ */
+ private void registerUpgradedPendingSegmentOnSupervisor(
+ Task task,
+ TaskActionToolbox toolbox,
+ List<PendingSegmentRecord> upgradedPendingSegments,
+ String supervisorId
+ )
+ {
+ final Map<String, Integer> notifiedTasksBySegment = new LinkedHashMap<>();
int registeredSegments = 0;
- int totalNotifiedTasks = 0;
for (PendingSegmentRecord upgradedPendingSegment :
upgradedPendingSegments) {
- final OptionalInt notified = supervisorManager
-
.registerUpgradedPendingSegmentOnSupervisor(activeSupervisorIdWithAppendLock.get(),
upgradedPendingSegment);
+ final OptionalInt notified = toolbox.getSupervisorManager()
+ .registerUpgradedPendingSegmentOnSupervisor(supervisorId,
upgradedPendingSegment);
if (notified.isEmpty()) {
continue;
}
final int notifiedCount = notified.getAsInt();
registeredSegments++;
- totalNotifiedTasks += notifiedCount;
- if (notifiedTasksSample.size() < NOTIFIED_LOG_SAMPLE_SIZE) {
- notifiedTasksSample.put(upgradedPendingSegment.getId().toString(),
notifiedCount);
- }
- if (debugEnabled) {
- notifiedTasksBySegment.put(upgradedPendingSegment.getId().toString(),
notifiedCount);
- }
+ notifiedTasksBySegment.put(upgradedPendingSegment.getId().toString(),
notifiedCount);
}
log.info(
- "Registered [%d] upgraded pending segment(s) created by task[%s] on
supervisor[%s], notifying [%d] running"
- + " task(s) in total. Tasks notified per segment%s: %s",
+ "Registered [%d] upgraded pending segment(s) created by task[%s] on
supervisor[%s]."
+ + " Tasks notified per segment %s: %s",
registeredSegments,
task.getId(),
- activeSupervisorIdWithAppendLock.get(),
- totalNotifiedTasks,
+ supervisorId,
registeredSegments > NOTIFIED_LOG_SAMPLE_SIZE ? " (first " +
NOTIFIED_LOG_SAMPLE_SIZE + ", enable debug for all)" : "",
- notifiedTasksSample
+
notifiedTasksBySegment.entrySet().stream().limit(NOTIFIED_LOG_SAMPLE_SIZE)
);
- if (debugEnabled && registeredSegments > NOTIFIED_LOG_SAMPLE_SIZE) {
- log.debug(
- "Tasks notified per segment created by task[%s] on supervisor[%s]:
%s",
- task.getId(),
- activeSupervisorIdWithAppendLock.get(),
- notifiedTasksBySegment
- );
- }
Review Comment:
Updated.
--
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]