FrankChen021 commented on code in PR #20291:
URL: https://github.com/apache/druid/pull/20291#discussion_r4034902768
##########
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:
Addressed in 64694425a9. Rather than coordinating with the in-flight
refresh, the metric emission is now idempotent: both `removeSegment` and the
null-signature branch of `refresh` emit `dataSource/removed` only when their
own `tables.remove(dataSource)` returned a non-null value. Since `tables` is a
`ConcurrentHashMap`, exactly one of the two paths wins the remove and emits;
the other sees `null` and stays silent, in either interleaving. The callback
still never touches the refresh thread's local `dataSourcesToRebuild` set, and
no lock is held across metadata queries.
Test coverage: `testLastSegmentRemovalClearsRebuildState` now also runs a
refresh that is handed the datasource explicitly after the last segment is gone
(simulating a refresh that captured it before the removal) and asserts the
metric count stays at 1. A new
`testRefreshOfUnknownDatasourceDoesNotEmitRemovalMetric` covers a datasource
that never had a table. Both fail on the previous revision (`expected: <1> but
was: <2>` / `expected: <0> but was: <1>`) and pass now.
The separate table-resurrection race (refresh re-inserting a table after the
last segment was removed) is pre-existing on master and not addressed here; I
will file it as a follow-up.
--
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]