Repository navigation
Isolate 00180_no_seek_avoiding_when_reading_from_cache from other cache users - #114245
PedroTadim merged 1 commit into
Conversation
…he users The test asserts that its measured query reads entirely from the filesystem cache, but the table is created with `CREATE TABLE hits_s3_sampled AS test.hits_s3`, so it inherits `storage_policy = 's3_cache'`: the single 200 MiB cache shared by everything on the server. Background merges of `test.hits_s3` write through that cache and can fill it with file segments held open by a `FileSegmentsHolder`, which are not releasable. The warm-up queries' space reservation then finds nothing to evict, silently continues without caching, and the measured query reads from S3, so `CachedReadBufferReadFromSourceBytes` is non-zero. `SYSTEM CLEAR FILESYSTEM CACHE` does not help, since it is `removeAllReleasable` and skips held segments. Give the table a private inline cache disk instead, keyed on `$CLICKHOUSE_DATABASE` so the disk name is unique per run and the test stays parallel-safe, and scope the cache clear to that cache. The assertion, the reference file and the tags are unchanged. `04695_filesystem_cache_wait_for_concurrent_download_timeout.sh` was isolated the same way in eca7e22 for this same mechanism. The explicit `ENGINE = MergeTree` is required. Without it, `setEngine` calls `inheritStorageFromSource`, whose `mergeStorageSettings` appends the source's `storage_policy` next to the new `disk` setting, and `loadFromQuery` then throws `storage_policy and disk cannot be specified at the same time`. With the engine given explicitly that path is skipped, while columns and the PARTITION BY / ORDER BY / SAMPLE BY clauses are still copied from the source table. Validated by reproducing the failure mode locally with a concurrent workload that keeps the shared cache full of held segments, confirmed by a global cache clear leaving 229.68 MiB across 46 segments resident. Runs of the real test file under that workload: 2 of 20 passed before this change, 50 of 50 after. With the same query and settings against a cold cache the asserted counters are 4607579 and 7944923, and against the warm private cache both are 0, so the assertion still catches the regression it exists for. Closes: ClickHouse#114213
Internal second-model review: 0 blocking findingsAn independent cold re-review of the full change returned 0 findings, covering the test and My own cold review raised five notes, all verified against the source and none blocking: 💡 The explicit 💡 The private cache runs on default 💡 The disk and cache are registered server-globally and outlive the table. No in-tree test queries 💡 Test liveness: the reference is byte-identical and both counters stay reachable exactly when the 💡 The placeholder changelog entry is correct for the Disclosed and not chased: an inline custom disk outlives its table and leaves a small cache |
Pre-PR validation gate
The assertion is not weakened. Same query and settings against a cold cache give |
|
cc @antonio2368, could you review this? The test's table inherits |
|
Workflow [PR], commit [20dea4f] Summary: ❌
AI ReviewSummaryThis PR changes Final Verdict✅ 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 sizes6 object files changed (+241.92 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 units6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger - 20dea4fEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Owner resolved from 175 jobs, 0 incomplete, 0 dropped, 39 green, 135 genuinely skipped (each with a config reason - Not caused by this PR: the diff only isolates Session id: cron:our-pr-ci-monitor:20260811-060000 |
24a4d5c
Closes: #114213
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
The test asserts that a query reads entirely from the filesystem cache, but its table inherits
storage_policy = 's3_cache'fromtest.hits_s3, so it shares one 200 MiB cache with everythingelse on the server. Background merges of
test.hits_s3write through that cache and can fill itwith file segments held open by a
FileSegmentsHolder. Reservation then finds nothing releasable toevict, both warm-up queries silently continue without caching, and the measured query reads from S3,
so
CachedReadBufferReadFromSourceBytesis non-zero.SYSTEM CLEAR FILESYSTEM CACHEcannot help:it removes only releasable segments.
Observed on
this run,
where the value was
10667287. Raisingfilesystem_cache_reserve_space_wait_lock_timeout_millisecondsand addingno-parallelwere bothtried before and neither addresses this: the failure is
cannot evict enough space, not lockcontention, and the competing cache user is the server's own background merge rather than another
test.
The fix gives the table a private inline cache disk, keyed on
$CLICKHOUSE_DATABASEso it staysunique per run, and scopes the cache clear to that cache. The assertion, the reference file and the
tags are unchanged. This mirrors
04695_filesystem_cache_wait_for_concurrent_download_timeout.sh,which was isolated the same way in
eca7e2270696c02for the same mechanism. The explicitENGINE = MergeTreeis required: without it the inheritedstorage_policyis merged next to the newdisksetting and the statement fails withstorage_policy and disk cannot be specified at the same time. Column and key clauses are still copied from the source table.Shared-cache eviction behaviour stays covered by the other tests on the
s3_cachepolicy.Validation: I reproduced the failure mode locally with a concurrent workload that keeps the shared
cache full of held segments, and synthesized
test.hits_s3so the real test could run.Validation detail
Under the concurrent workload, a global
SYSTEM CLEAR FILESYSTEM CACHEleft 229.68 MiB across 46segments resident, and the server log showed the failing job's signature
releasable size: 0, releasable count: 0, non-releasable size: 207535569.Runs of the real test file via
clickhouse-test, same binary and same workload:All 18 failures are the assertion itself, with values such as
0 12123319, matching the magnitudeseen in CI.
The assertion still catches what it exists for. With the same query and settings against a cold
cache,
AsynchronousReaderIgnoredBytesis4607579andCachedReadBufferReadFromSourceBytesis7944923; against the warm private cache both are0.Version info
26.8.1.1214(included in26.8and later)