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


##########
server/src/main/java/org/apache/druid/segment/metadata/AbstractSegmentMetadataCache.java:
##########
@@ -615,6 +616,9 @@ public void removeSegment(final DataSegment segment)
             }
           }
       );
+      if (remainingSegments == null) {
+        dataSourcesNeedingRebuild.remove(segment.getDataSource());

Review Comment:
   [P2] Prevent duplicate removal metrics from in-flight refresh
   
   This clears only the shared `dataSourcesNeedingRebuild` set. A cache refresh 
can already have copied that datasource into its local `dataSourcesToRebuild` 
set at the end of `BrokerSegmentMetadataCache.refresh` before this callback 
removes the last segment. The callback then emits `DATASOURCE_REMOVED`, but the 
same refresh still builds the now-empty datasource and emits 
`DATASOURCE_REMOVED` again. Coordinate this cleanup with the in-flight refresh 
(or make the removal emission idempotent), and cover the callback/refresh 
interleaving so one removal is counted once.



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