mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2026-10-28 16:18:23 +08:00
`test_cache_size` only asserted the completed-segment projection of the contract: by the time it reads `FilesystemCacheSize`, every touched file segment is fully downloaded, so `reserved_size == downloaded_size` and a bug in the block-aligned accounting of the reserve-ahead surplus would leave the test green. Add `test_cache_size_partial_segment_reserve_ahead`, which uses a cache disk with an explicit 4Mi `reserve_granularity` and reads a single granule out of a table whose column files are several times larger. That leaves the file segment in the `reserved_size > downloaded_size` state, so completing it has to return `alignFileSize(reserved_size) - alignFileSize(downloaded_size)` rather than the raw difference; the test pins both `FilesystemCacheSize` and `current_size` in `system.filesystem_cache_settings` to the block-aligned downloaded footprint, and asserts that the read really was partial. Also disable background download in `test_cache_size` so nothing can fill the cache between reading the metric and computing the expectation, and state in a comment which part of the contract that test covers.