Flaky test: ClusterByStatisticsCollectorImplTest.test_clusterByXYbucketByX_threeX_uniqueY
This issue was generated automatically by Claude Code (Anthropic's AI coding agent) running a scheduled CI-triage routine on behalf of @FrankChen021. Analysis and suggested fixes are AI-produced; please verify before acting on them.
Status: Open: no fix PR
Subject: ClusterByStatisticsCollectorImplTest.test_clusterByXYbucketByX_threeX_uniqueY (multi-stage-query, unit tests (25, C*))
Failures: 0 job failures, 4 passed on retry · First seen: 2026-09-26 · Last seen: 2026-09-27
So far every occurrence failed its first attempt and then passed on a surefire rerun (surefire.rerunFailingTestsCount=3), so no job has failed yet. It is tracked because it happened 4 times in 2 days.
Root cause
The single collector, random order case fails in verifyPartitionWeights because one partition from generatePartitionsWithMaxCount(50) falls outside PARTITION_SIZE_LEEWAY (0.35). The test seeds its key shuffle (new Random(7)), but QuantilesSketchKeyCollector uses DataSketches ItemsSketch. In datasketches-java 4.2.0, ItemsSketch.rand is a public static Random that is never seeded. The sketch calls nextBoolean() on it when it compacts and nextInt() when it merges, so the partition boundaries change from run to run, and sometimes a partition lands outside the tolerance. The failing partition index differs each time (#1, #2, #3, #32). None of the commits touches multi-stage-query/.../statistics.
Suggested fix
In ClusterByStatisticsCollectorImplTest, call ItemsSketch.rand.setSeed(<constant>) in a @BeforeEach so the sketch compacts the same way every run. Alternatively, derive the allowed partition size from the sketch's normalized rank error instead of the fixed 35%.
Occurrences
Push-triggered master jobs where this test failed at least one attempt. The daily triage routine adds one row per new job.
| Date | Commit | Job | Failure log | Detail | Reported in |
|---|---|---|---|---|---|
| 2026-09-26 | 017c18ab6d (#19858) | unit tests (25, C*) |
job 108333544432 | partition #32 row count outside leeway; 1 of 2 attempts failed (passed on retry) | #20437 |
| 2026-09-26 | e16bbf8bdc (#20413) | unit tests (25, C*) |
job 108335302789 | partition #2; 1 of 2 attempts failed (passed on retry) | #20437 |
| 2026-09-27 | 13749ce533 (#20314) | unit tests (25, C*) |
job 108520336133 | partition #1; 1 of 2 attempts failed (passed on retry) | |
| 2026-09-27 | 7a7b9f2a8a (#20409) | unit tests (25, C*) |
job 108537558789 | partition #3; 1 of 2 attempts failed (passed on retry) |
Source: apache/druid