Repository navigation
Keep the part's type in storage of columns that a mutation carries over - #123643
alexey-milovidov wants to merge 10 commits into
Conversation
`max_local_read_bandwidth_for_server` and the per-query `max_local_read_bandwidth` exist to keep the load that ClickHouse puts on the block devices within a budget, but they accounted the bytes copied from the OS page cache exactly like the bytes that hit the disk. A query whose data is fully cached in RAM was slowed down to the configured disk bandwidth while producing almost no block device I/O, which makes the setting useless for its purpose: it has to be set at the disk bandwidth or above (and then it protects nothing), or below it (and then it penalizes cached reads). `ThreadPoolReader` already knows whether a read was served from the page cache - it tries `preadv2` with `RWF_NOWAIT` first and falls back to the thread pool on `EAGAIN`. Report that in `IAsynchronousReader::Result` and skip the throttler for such reads. This covers the default `local_filesystem_read_method = 'pread_threadpool'`; the synchronous `pread` methods cannot tell whether the data was cached, and reads with `O_DIRECT` always reach the device, so both keep being accounted. Closes: #118463
`02703_max_local_read_bandwidth` and `test_throttling` read data that they have just written, so it is in the OS page cache and is no longer accounted by the local read throttler when the default `pread_threadpool` read method is used. Read with `pread`, which cannot tell a cached read from a device read, and cover the `pread_threadpool` accounting in `05111_local_read_throttler_page_cache`.
…cache-reads # Conflicts: # src/Core/ServerSettings.cpp
`ReadSettings::local_throttler` is not always the throttler of `max_local_read_bandwidth`: `BackupsWorker` and `MergeTreeSequentialSource` combine it with the throttlers of `max_backup_bandwidth`, `max_merges_bandwidth` and `max_mutations_bandwidth` through `ThrottlerArray`. Skipping the whole composite throttler for the data that came from the OS page cache disabled those limits as well, which broke `02704_max_backup_bandwidth` - a backup of a freshly inserted table was not throttled at all. Only the throttlers created by `Context::getLocalReadThrottler` model the bandwidth of the block device, so mark them with `Throttler::setLimitsBlockDeviceBandwidth` and route the page cache reads through the new `IThrottler::throttleOSPageCacheRead`, which skips exactly those and accounts the read in all the others. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…hrottler The test required `QueryLocalReadThrottlerBytes` to be exactly `ThreadPoolReaderPageCacheMissBytes`, but the query also reads small metadata files synchronously with the `read` method (which cannot tell a cached read from a device read, so it is throttled), and a prefetched buffer can be discarded unconsumed. Reproduced locally with the randomized settings: one 4096-byte synchronous read made the throttler count 4096 bytes with zero thread pool misses. Check instead that the throttler accounts at most the bytes that were not page cache hits. The test cannot pass on macOS, where there is no `preadv2` with `RWF_NOWAIT`, so mark it `no-darwin`. Also address the review: `test_local_read_throttling_reload` now checks that a `pread_threadpool` scan of cached data is not throttled by the `max_local_read_bandwidth_for_server` throttler created on config reload. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118495&sha=816d62734cc54d0ed78a622bb3643de7da03a028&name_0=PR PR: #118495 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # src/Interpreters/Context.cpp
`ThreadPoolReader` reports `ThreadPoolReaderPageCacheHitBytes` only when `preadv2` with `RWF_NOWAIT` is usable. On old kernels, under `seccomp` profiles, or on filesystems rejecting the flag, every read falls back to `pread`, so requiring page cache hits made the tests fail on supported environments. Keep only the accounting invariant in `05111_local_read_throttler_page_cache`, and check the duration in `test_local_read_throttling_reload` only when page cache hits happened. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…age cache The files of the filesystem cache (`CachedOnDiskReadBufferFromFile` and `DiskCacheProvider`) are always read with `LocalFSReadMethod::pread`, so a query served from a hot cache file still consumed the tokens of `max_local_read_bandwidth` and was slowed down to the disk speed. `ReadBufferFromFileDescriptor` with `pread` now tries `preadNoWait` first when there is a throttler, the file is not opened with `O_DIRECT`, and the system call is usable, and reports such reads with `throttleOSPageCacheRead`. This covers the cache files and `local_filesystem_read_method = 'pread'`; the `read` method still cannot tell a cached read from a device read. The new `ReadBufferFromFileDescriptorPageCacheHitBytes` profile event counts the detected bytes. The throttling tests that relied on `pread` being throttled for cached data now use `read`, and `05317_local_read_throttler_filesystem_cache` checks the accounting for a warmed-up filesystem cache. #118495 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`getColumnsForNewDataPart` replaced only `NameAndTypePair::type` of a column in the new part's column list, leaving `type_in_storage` with the type from the metadata. When an `ALTER MODIFY COLUMN` mutation of a `Nested` member was killed and a later mutation hardlinked that member, the new part's column list had, for example, `n.a` with type `Array(UInt32)` but type in storage `QBit(Int8, 70)`. `Nested::collect` groups by the type in storage, so it dropped `n.a` from the collected columns of the part, the reader treated the column as missing in the part, and reading it threw a logical error: `Stream n%2Ea%2E1 for column n.a with type QBit(Int8, 70) is not found`. Assign the whole `NameAndTypePair` instead. Stress test (azure, amd_msan) failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=35a35bc242ed2597e37016a924ccea5aea7bea41&name_0=MasterCI&name_1=Stress%20test%20%28azure%2C%20amd_msan%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [b51e19a] Summary: ❌
|
|
🕵 Closing as already fixed on Also note that this branch was created on top of the Related: #121561 |
A mutation that hardlinks a column it does not touch records the type the source part has for that column, but
getColumnsForNewDataPartreplaced onlyNameAndTypePair::typeand lefttype_in_storagewith the type from the metadata. After anALTER MODIFY COLUMNof aNestedmember was killed and a later mutation carried the member over, the new part listed e.g.n.aasArray(UInt32)with type in storageQBit(Int8, 70).Nested::collectgroups by the type in storage, so it droppedn.afrom the collected columns of the part, the reader treated the column as missing in the part, and reading it threw a logical errorStream n%2Ea%2E1 for column n.a with type QBit(Int8, 70) is not found.The fix assigns the whole
NameAndTypePair.Found by the stress test: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=35a35bc242ed2597e37016a924ccea5aea7bea41&name_0=MasterCI&name_1=Stress%20test%20%28azure%2C%20amd_msan%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix an exception
Stream ... is not foundwhen reading aNestedmember after itsALTER MODIFY COLUMNmutation was killed and another mutation was applied to the part.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123643]