FrankChen021 commented on code in PR #20247:
URL: https://github.com/apache/druid/pull/20247#discussion_r3970100441


##########
server/src/main/java/org/apache/druid/server/coordinator/duty/CloneHistoricals.java:
##########
@@ -120,6 +126,12 @@ public DruidCoordinatorRuntimeParams 
run(DruidCoordinatorRuntimeParams params)
         if (shouldLoadSegmentOnTargetServer(segment, sourceProfile, 
targetServer, targetProjectedSegments)) {
           loadSegmentOnTargetServer(segment, sourceProfile, targetServer, 
params);
         }
+
+        if (params.isUsedSegment(segment)

Review Comment:
   [P1] Do not mark a clone synced while a source segment remains unsynced
   
   A used segment that is served by the source is counted as pending only when 
`targetServer.isLoadingSegment(segment)` is true. If the target already has a 
queued `DROP` from an earlier reconciliation, or the attempted load is rejected 
or fails and is cancelled, the target is neither serving nor loading, so this 
condition contributes zero and `isSynced` can report `SYNCED` while the target 
is about to drop or miss a source segment. Count every source-served segment 
that remains unsynced after reconciliation, or clear/replace the conflicting 
target action, before applying the thresholds.



##########
server/src/main/java/org/apache/druid/server/coordinator/duty/CloneHistoricals.java:
##########
@@ -110,6 +113,9 @@ public DruidCoordinatorRuntimeParams 
run(DruidCoordinatorRuntimeParams params)
         continue;
       }
 
+      final CloningStats cloningStats = new 
CloningStats(sourceServer.getServer().getNumSegments());

Review Comment:
   [P2] Exclude unused source segments from the sync percentage
   
   `getNumSegments()` counts every segment currently in the source server 
inventory, including segments already marked unused and queued for removal, 
while `segmentsPendingSync` only increments for 
`params.isUsedSegment(segment)`. Until those stale inventory entries are 
dropped, they inflate the denominator and can make a clone with a meaningful 
used-segment backlog appear within `maxPercentPendingSync`. Derive the 
denominator from the used/projected source segments that are eligible for 
cloning.



##########
docs/operations/metrics.md:
##########
@@ -468,6 +471,8 @@ These metrics are emitted by the Druid Coordinator in every 
run of the correspon
 |`segment/underReplicated/count`|Number of segments, including replicas, left 
to load until all used segments are available for queries.|`tier`, 
`dataSource`|0|
 |`segment/availableDeepStorageOnly/count`|Number of unique segments that are 
only available for querying directly from deep storage.|`dataSource`|Varies|
 |`tier/historical/count`|Number of available historical nodes in each tier. 
The `tierAlias` dimension is emitted only when the tier belongs to an alias 
configured via 
[`historicalTierAliases`](../configuration/index.md#dynamic-configuration), and 
can be used to aggregate metrics across the tiers in an alias.|`tier`, 
`tierAlias`|Varies|
+|`tier/historical/clone/count`|Number of historical nodes in a tier which are 
a clone of another historical in the same or different tier. The `tierAlias` 
dimension is emitted only when the tier belongs to an alias configured via 
[`historicalTierAliases`](../configuration/index.md#dynamic-configuration), and 
can be used to aggregate metrics across the tiers in an alias.|`tier`, 
`tierAlias`|Varies|
+|`tier/historical/clone/synced`|Number of historical clones in a tier which 
are currently in sync with their source server. |`server`, `tier`|1 if synced, 
O if not synced|

Review Comment:
   [P3] Document zero for the unsynced gauge value
   
   The normal value says `O` (the letter O) for the unsynced value, while 
`collectMetrics` emits numeric `0`. Change this to `0` so the metric contract 
is unambiguous.



-- 
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]

Reply via email to