Repository navigation
Fix flaky 04511_reader_executor_disk_cache - #115643
Conversation
The test asserted that the warm reread pulls strictly fewer source bytes
than the cold read. That is a proxy, and a partially populated cache
inverts it, so the test failed on master:
-warm_served_from_cache 1
+warm_served_from_cache 0
With more than one reading thread, every stream builds its own
`ReaderExecutor` over the same file. `DiskCacheWriter` appends only at
the segment's live write offset, so whichever stream loses the
downloader race contributes nothing and the cold read leaves the segment
partially populated. The warm read then re-fetches such a segment from
its start - `claimLeadRole`'s `available` prefix is deliberately unused,
see the "Coarse by design" note in `ReaderExecutor::readThroughCaches` -
and can move MORE source bytes than the cold read did.
The failing run shows exactly this: the cold read populated 285856 of
the 801126-byte segment and read 1658884 bytes from source, and the warm
read then read 2480460. Across the 28 runs of that job the warm total
was 0, 801126, 1372817, 1479995 or 2480460 depending only on how the
streams interleaved.
Pin the reads to one thread, so the cold read populates the whole
segment, and assert the strong property instead of the proxy: the warm
read must touch the source not at all. Verified with 54 runs of the
test under randomized settings against a local minio; `cold` is now a
stable 800461 (one clean pass over the file rather than two or three
overlapping ones) and `warm` is 0 in every run.
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=2101f9b0850389d7fddfefd04d2577162c8958c3&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20sequential%2C%202%2F2%29
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [ec1274a] Summary: ✅ AI ReviewSummaryThis PR fixes the flakiness in Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes49 object files changed (+4.20 KiB total), 0 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline. |
04511_reader_executor_disk_cachefails on master withCI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=2101f9b0850389d7fddfefd04d2577162c8958c3&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20sequential%2C%202%2F2%29
It also fails on unrelated pull requests in
Stateless tests (amd_msan, WasmEdge, sequential, 2/2)(4 of 14 reruns there). No tracking issue exists.What goes wrong
The third check asserted
warm < cold, comparing theReaderExecutorBytesFromSourcetotals of a cold and a warmSELECT. That is a proxy, and a partially populated cache inverts it.With more than one reading thread each stream builds its own
ReaderExecutorover the same file.DiskCacheWriterappends only at the segment's live write offset, so whichever stream loses the downloader race contributes nothing, and the cold read leaves the segment partially populated. The warm read then re-fetches such a segment from its start —claimLeadRole'savailableprefix is deliberately unused, see the "Coarse by design" note inReaderExecutor::readThroughCaches— so it can move more source bytes than the cold read did.The failing job's server log and
query_logshow exactly that: the cold read populated 285856 of the 801126-byte segment and read 1658884 bytes from source; the warm read then read 2480460. Across the 28 runs of that job the cold total was a constant 1658884 while the warm total was 0, 801126, 1372817, 1479995 or 2480460, purely as a function of how the streams interleaved.The fix
Pin the reads to a single thread, so the cold read populates the segment completely, and assert the strong property instead of the proxy: the warm read must touch the source not at all (
warm = 0).Verified over 54 runs of the test with randomized settings against a local minio:
coldis now a stable 800461 (one clean pass over the file instead of two or three overlapping ones) andwarmis 0 in every run.The re-fetch-from-segment-start behaviour itself is left alone — it is a documented limitation of the experimental
ReaderExecutorwith a follow-up already noted in the code, not something to change in a CI fix.Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/115643]