FrankChen021 commented on code in PR #20320:
URL: https://github.com/apache/druid/pull/20320#discussion_r4070488858
##########
services/src/test/java/org/apache/druid/testing/embedded/EmbeddedClusterApis.java:
##########
@@ -281,21 +282,41 @@ public List<Interval> getSortedSegmentIntervals(String
dataSource, EmbeddedOverl
*/
public void verifyNumVisibleSegmentsIs(int numExpectedSegments, String
dataSource, EmbeddedOverlord overlord)
{
- int segmentCount = getVisibleUsedSegments(dataSource, overlord).size();
+ final Set<DataSegment> visibleSegments =
getVisibleUsedSegments(dataSource, overlord);
+ final int segmentCount = visibleSegments.size();
Assertions.assertEquals(
numExpectedSegments,
segmentCount,
"Segment count mismatch"
);
- Assertions.assertEquals(
- String.valueOf(segmentCount),
- runSql(
- "SELECT COUNT(*) FROM sys.segments WHERE datasource='%s'"
- + " AND is_overshadowed = 0 AND is_available = 1",
- dataSource
- ),
- "Segment count mismatch in sys.segments table"
- );
+
+ // The Broker learns about segment changes asynchronously from the
Coordinator, so the
+ // sys.segments table may briefly lag behind the metadata store. Match the
segment IDs as well
+ // as the count because compaction can replace segments without changing
their number.
+ final String expectedCount = String.valueOf(segmentCount);
+ final String expectedSegmentIds = visibleSegments
+ .stream()
+ .map(segment -> StringUtils.format("'%s'",
StringUtils.escapeSql(segment.getId().toString())))
Review Comment:
Fixed in 91e4fec774. The complete segment-ID predicate is now passed through
a `%s` argument to `runSql` instead of being concatenated into its format
template, so percent sequences inside valid IDs remain literal SQL data. `git
diff --check` and focused `services` test compilation passed.
--
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]