FrankChen021 commented on code in PR #19413:
URL: https://github.com/apache/druid/pull/19413#discussion_r3208921253
##########
server/src/main/java/org/apache/druid/server/coordinator/loading/StrategicSegmentAssigner.java:
##########
@@ -264,34 +293,56 @@ public void replicateSegment(DataSegment segment,
Map<String, Integer> tierToRep
// Update replicas in every tier
int dropsQueued = 0;
for (String tier : allTiersInCluster) {
+ final int requiredReplicas =
effectiveTierToReplicaCount.getOrDefault(tier, 0);
+ final Set<String> groupsInTier = tierToActiveGroups.get(tier);
+ if (groupsInTier != null) {
Review Comment:
[P2] Ungrouped replicas are skipped once a coordinated group exists
When coordinatingVersions is non-empty and a tier has at least one
coordinated deployment group, this branch only updates those group-scoped keys
and then continues. Replicas counted under the tier-wide key, such as servers
with null deploymentGroup or groups not in coordinatingVersions, are never
visited for drops or cancelled loads. During mixed deployments or after
disabling a group, segments on those servers can remain loaded even when the
rule requires zero replicas. The update loop should also process the tier-wide
scope for uncoordinated servers, or explicitly drop/exclude those replicas.
##########
server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java:
##########
@@ -1010,4 +1039,49 @@ static boolean
isSegmentLoaded(Iterable<ImmutableSegmentLoadInfo> servedSegments
return false;
}
+ /**
+ * Builds a {@code tier -> activeGroups} map in a single pass over the
server inventory. Only
+ * segment-replication-target servers whose {@code deploymentGroup} is in
+ * {@code coordinatingVersions} contribute. Tiers with no active groups are
absent from the
+ * returned map. Groups with no online servers do not block handoff.
+ */
+ private Map<String, Set<String>>
computeActiveDeploymentGroupsByTier(Set<String> coordinatingVersions)
+ {
+ final Map<String, Set<String>> activeGroupsByTier = new HashMap<>();
+ for (DruidServer server : serverInventoryView.getInventory()) {
+ if (!server.getType().isSegmentReplicationTarget()) {
+ continue;
+ }
+ final String group = server.getMetadata().getDeploymentGroup();
+ if (group == null || !coordinatingVersions.contains(group)) {
+ continue;
+ }
+ activeGroupsByTier.computeIfAbsent(server.getTier(), t -> new
HashSet<>()).add(group);
+ }
+ return activeGroupsByTier;
+ }
+
+ /**
+ * Returns true if at least one segment-replication-target server in {@code
group} serves the segment
+ * described by {@code descriptor}.
+ */
+ static boolean isSegmentLoadedForDeploymentGroup(
+ Iterable<ImmutableSegmentLoadInfo> servedSegments,
+ SegmentDescriptor descriptor,
+ String group
+ )
+ {
+ for (ImmutableSegmentLoadInfo segmentLoadInfo : servedSegments) {
+ if
(segmentLoadInfo.getSegment().getInterval().contains(descriptor.getInterval())
+ && segmentLoadInfo.getSegment().getShardSpec().getPartitionNum() ==
descriptor.getPartitionNumber()
+ &&
segmentLoadInfo.getSegment().getVersion().compareTo(descriptor.getVersion()) >= 0
+ && segmentLoadInfo.getServers().stream().anyMatch(
Review Comment:
[P2] Handoff group check ignores the required tier
The per-group handoff check iterates each tier from the matching load rule,
but isSegmentLoadedForDeploymentGroup only checks that some replication-target
server in the group serves the segment. If the same deploymentGroup name exists
in multiple tiers, a segment served by red in tier2 can satisfy the red check
for tier1, causing /handoffComplete to return true before the segment is loaded
in the rule-required tier. Pass the tier into this helper and require the
serving server tier to match the tierEntry being evaluated.
--
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]