Repository navigation
Fix flaky test 02770_async_buffer_ignore - #107298
PedroTadim merged 4 commits into
Conversation
The test asserted exact S3 read profile-event counts (S3ReadRequestsCount, ReadBufferFromS3Bytes, ReadCompressedBytes) for a narrow-range read. Those counts are non-deterministic across CI jobs: filesystem cache hits drop ReadBufferFromS3Bytes to ~830, parallel replicas raise the request count, and S3 read-ahead inflates the byte counts. Over 90 days this produced 212 failures across 12 unrelated PRs. Assert bounds instead: a narrow read of 2001 of 1000000 rows must not pull the whole part (~4 MB compressed per column), so S3ReadRequestsCount stays small and ReadCompressedBytes stays far below the full-column size. This still catches the over-read regression the test guards against while tolerating cache, read-ahead, and parallel-replica variance. Mirrors the approach in 03164_s3_settings_for_queries_and_merges. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-2:20260611-231200 |
|
cc @kssenii — could you review this? It is a test-only fix for the flaky |
|
Workflow [PR], commit [f1e0782] Summary: ✅ AI ReviewSummaryThis PR rewrites Missing context / blind spots
Final Verdict✅ No new review findings. I would let CI finish, but I do not have an inline blocker to post on this PR. |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 279 line(s), 45 function(s) across 113 file(s) · Details Top files
|
CI summary — HEAD 6ce2baeCI has fully finished (Finish Workflow: success). The fix target Two unrelated failures remain, neither caused by this test-only
This PR only changes |
The bounded rewrite of this test stopped the chronic result-differs flake but left no assertion able to observe the defect the test exists for. That defect was AsynchronousBoundedReadBuffer::seek taking the lazy-ignore branch while file_offset_of_buffer_end was still 0, so the buffer downloaded the whole prefix ahead of the first needed granule and discarded it. Reproduced by removing the file_offset_of_buffer_end && guard together with the !current_buf || short-circuit in ReadBufferFromRemoteFSGather::isSeekCheap - the second is required, otherwise isSeekCheap() is true on the first seek and the branch is unreachable. The narrow read then transfers 853846 S3 bytes instead of 66446, of which 787400 are discarded. ReadCompressedBytes cannot see any of that. It is incremented in CompressedReadBufferBase for blocks handed to the decompressor, while the ignored prefix is dropped in ThreadPoolRemoteFSReader::execute before a block is assembled. On the buggy build it reads 66446, byte-for-byte equal to the healthy build, so no threshold on it can fail on the over-read: not < 1000000, not < 100000, not the exact 66446 the reference used to pin. Assert AsynchronousReaderIgnoredBytes = 0 instead: this query seeks each column once from offset 0, so a correct lazy ignore never triggers. Add RemoteFSSeeks > 0 and pin remote_filesystem_read_method so the check cannot pass vacuously on the synchronous path, which has no async buffer at all (that path reports RemoteFSSeeks 0 and ignored 0 even on the buggy build). no-random-settings already stops the runner selecting it, so this guards against the default changing, the tag being dropped, or the test being edited onto that path. ReadCompressedBytes < 1000000 is kept as a granule-selection bound with a comment that no longer overstates it; ReadBufferFromS3Bytes stays dropped as the unstable raw-transfer count. Verified both directions with Build IDs recorded: healthy build prints 1 1 1 1 10/10 and 15/15 on a fresh database; with the two guards removed it prints 1 0 1 1 10/10, so only the new column reacts. AsynchronousReaderIgnoredBytes is 0 across the regimes that destabilized the old assertion - repeat reads, prefetch off, method read, max_threads 1 and 16, remote_read_min_bytes_for_seek 0, parallel replicas, larger prefetch steps and read buffer.
CI finish ledger - 2cf39d3Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The job is otherwise clean: no test failed, only these two log-scanner pseudo-tests. Session id: cron:our-pr-ci-monitor:20260728-090000 |
|
@groeneai is this pr still relevant? |
|
Yes, still relevant, and it applies to master unchanged (the two test files only, no conflicts). The two source predicates the measurement in the description rests on are byte-identical on master today ( The flakiness pressure is lower than it was in June, and I would rather say so than oversell it: on master this test has 12991 OK rows and 0 failures in the last 30 days, and the last master failure was 2026-07-26. It still costs other people's PRs red jobs. Last 30 days, 13 failures across 3 PRs:
The branch is 28801 commits behind and untouched since 2026-07-28. I will leave it as it is unless you want a fresh CI run, in which case I will merge master. |
Related: #100391
Related: #106231
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes the flaky test
02770_async_buffer_ignore, and makes it assert the regression it was written for. Investigated at the request of alexey-milovidov on #100391, raised again on #106231.The flake
The test asserted exact S3 read profile-event counts for a narrow-range read:
against the reference
4 66446 66446. Those counts are not deterministic across CI jobs and the test cannot pin them away (it is alreadyno-random-settings). Over 120 days CIDB shows 253 failures across 28 distinct observed triples, 7 of them on master, first seen 2026-03-26. The largest groups are4 830 66446(x174, filesystem cache hit),6 67909 67909(x22, parallel replicas),4 7223260 66446(x5, S3 read-ahead),7 825111 569492(x5),4 17844 17844(x5), and a long tail of4 66446 679xx/4 66446 66533where onlyReadCompressedBytesdrifts by tens to ~1700 bytes. The two most recent master hits are4 66446 68063(2026-07-26) and4 66446 66533(2026-07-27).What the test guards, and why no bound on
ReadCompressedBytescan guard itThe regression fixed together with this test was
AsynchronousBoundedReadBuffer::seektaking the lazy-ignore branch whilefile_offset_of_buffer_endwas still 0, so the buffer downloaded the whole prefix ahead of the first needed granule and discarded it.I reproduced that by removing the
file_offset_of_buffer_end &&guard inAsynchronousBoundedReadBuffer::seektogether with the!current_buf ||short-circuit inReadBufferFromRemoteFSGather::isSeekCheap(the second one is required, otherwiseisSeekCheap()returns true on the first seek and the branch is unreachable). On this fixture the narrow read then transfers 853846 S3 bytes instead of 66446, of which 787400 are discarded.ReadCompressedBytesdoes not move at all: it is incremented inCompressedReadBufferBasefor blocks handed to the decompressor, while the ignored prefix is dropped lower down inThreadPoolRemoteFSReader::executebefore any block is assembled. On the buggy buildReadCompressedBytesis 66446, byte-for-byte equal to the healthy build. So no threshold on it can detect the over-read: not< 1000000, not< 100000, not even the exact66446the reference used to pin. The previous revision of this PR claimed the 1 MB bound would still catch an over-read; that claim was wrong and is retracted.Measured, narrow read, healthy vs buggy:
S3ReadRequestsCountReadBufferFromS3BytesReadCompressedBytesAsynchronousReaderIgnoredBytesThe fix
Assert the counter that actually observes the defect. The query seeks each column once, from offset 0, so a correct lazy ignore never triggers and
AsynchronousReaderIgnoredBytesis exactly 0:RemoteFSSeeks > 0is an activation check. Withremote_filesystem_read_method = 'read'there is noAsynchronousBoundedReadBufferat all, so the ignored-bytes assertion would pass vacuously: on the buggy build, methodreadreportsRemoteFSSeeks0 andAsynchronousReaderIgnoredBytes0 whilethreadpoolreports 2 and 787400.tests/clickhouse-testdoes randomizeremote_filesystem_read_methodoverreadandthreadpool, but the existingno-random-settingstag already suppresses that for this test, so the pin and the assertion are not guarding against the current randomizer: they guard against the default changing, the tag being dropped, or the test being edited onto the synchronous path, any of which would silently turn the ignored-bytes check into a no-op.ReadCompressedBytes < 1000000is kept as a granule-selection bound (a whole-column read is ~4 MB compressed), with a comment that no longer overstates what it covers.ReadBufferFromS3Bytesstays dropped: it is the unstable raw-transfer count (830 on a cache hit, 7.2 MB under read-ahead).Verification
Local server over MinIO
s3_disk(same disk definition astests/config/config.d/storage_conf.xml), Build IDs recorded for each direction:66c6aded:1 1 1 1, 10/10, and stable 15/15 on a fresh database.0c2a53f6:1 0 1 1, 10/10. Only the new column reacts; the two surviving bounds print1 1on the buggy build, which is exactly the coverage gap this change closes.RemoteFSSeeks0 / ignored 0 for methodread(bug invisible, caught by the activation assertion) versusRemoteFSSeeks2 / ignored 787400 forthreadpool.AsynchronousReaderIgnoredBytesis 0 across the regimes that made the old assertion flaky: repeated reads, prefetch off,max_threads1 and 16,remote_read_min_bytes_for_seek = 0, parallel replicas, larger prefetch steps, larger read buffer.This flake is unrelated to #100391: the query has no
ORDER BY, so the read-in-order path that PR changes is not exercised.Workflow [PR]
Sync PR [sync-upstream/pr/107298]
Version info
26.10.1.75(included in26.10and later)