Repository navigation
Sync changes - #115630
Sync changes#115630
Conversation
Sync cache-related changes from clickhouse-private master into the shared src/ files: - CachedOnDiskWriteBufferFromFile: recover write-through caching when a covering file segment stayed behind the written offset (mid-segment failover): shrink it and start a new file segment instead of throwing a logical error. New profile events CachedWriteBufferCoveringSegmentShrunk and CachedWriteBufferCoveringSegmentShrinkFailed, plus a chart on the Filesystem cache dashboard and the distributed_cache_write_simulate_mid_segment_failover failpoint. - CachedOnDiskReadBufferFromFile: count CachedReadBufferCacheWriteStopped when switching to REMOTE_FS_READ_BYPASS_CACHE. - CacheUsage: use the wall clock for the idle-client TTL, track created_at, expose getLastAccess (empty for clients loaded from the filesystem on startup), and count the TTL from creation while the last access is unknown. The startup load no longer counts as a client access in Metadata::getKeyMetadata. IFileCachePriority::UsageStat gains last_access_time. - Metadata: assert that user_id has no NUL or '/' in the per-user cache path. - ProfileEvents: add the DistrCache* seek events of the distributed cache read buffer. - FailPoint: drop the unused distributed_cache_cancel_query_in_response_wait. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [1181618] Summary: ❌
AI ReviewSummaryThis sync PR moves the distributed-cache read/write switches from profile settings to server settings and refactors filesystem-cache eviction/resize logic, including idle-client cleanup. The PR is not ready to merge: the distributed-cache migration breaks backward-compatibility in two separate ways, and the new idle-client TTL logic now depends on wall-clock jumps. Missing context / blind spots
Findings❌ Blockers
Tests
Final Verdict❌ Changes required before merge: the distributed-cache setting migration still breaks backward compatibility, and the filesystem-cache idle-client TTL should not depend on wall-clock jumps. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 842/1032 (81.59%) · Uncovered code |
Sync the move of `read_through_distributed_cache` / `write_through_distributed_cache` from query settings to server settings (private commits 68119670a70, 060f7c2c4fc). Merges, mutations and `Buffer` flushes run in contexts built once at startup, so the profile-level switches stayed pinned to whatever the server started with; as server settings they are shared by every context and refreshed from the config reload handler, reported as `changeable_without_restart`. Per-query control remains via the new `BoolAuto` settings `force_read_through_distributed_cache` / `force_write_through_distributed_cache` (`auto` follows the server setting). The old query-level settings become `MAKE_DEPRECATED_BY_SERVER_CONFIG` and stay in the profile allowlist of `ServerSettingsImpl::loadSettingsFromConfig`. The overrides are resolved in `Context::resolveReadThroughDistributedCache` / `resolveWriteThroughDistributedCache` instead of resetting the global context, which raced with concurrent readers of the global settings (TSan report in private PR 67632). Also add the `distributed_cache_client_id` query setting (CI tests only). Co-Authored-By: Claude Fable 5 <[email protected]>
| MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_distributed_schedule_pool_size, 16) \ | ||
| MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, max_remote_read_network_bandwidth_for_server, 0) \ | ||
| MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, max_remote_write_network_bandwidth_for_server, 0) \ | ||
| MAKE_DEPRECATED_BY_SERVER_CONFIG(M, Bool, read_through_distributed_cache, false) \ |
There was a problem hiding this comment.
Making the old names MAKE_DEPRECATED_BY_SERVER_CONFIG turns existing session/profile overrides into silent no-ops, because the actual read/write path now only consults force_read_through_distributed_cache / force_write_through_distributed_cache (Context::resolveReadThroughDistributedCache / resolveWriteThroughDistributedCache). We still have in-tree consumers that rely on the old behavior, for example tests/queries/0_stateless/00170_s3_cache.sql, tests/queries/0_stateless/02770_async_buffer_ignore.sh, and the ci_logs_sender profile in tests/config/users.d/ci_logs_sender.yaml. After this change those settings still parse, but they no longer enable or disable distributed cache. Please either alias the old query/profile settings to the new force_* ones, or migrate every existing consumer in the same PR.
| using Clock = std::chrono::steady_clock; | ||
| /// The wall clock, so that the last access can be reported as is in system tables. | ||
| /// The value does not survive a restart anyway, so monotonicity buys nothing here. | ||
| using Clock = std::chrono::system_clock; |
There was a problem hiding this comment.
Switching the idle-client TTL to system_clock makes eviction depend on wall-clock jumps. An NTP step, VM resume, or manual clock correction can suddenly make every client look idle (or keep dead clients alive after a backward step), and FileCache::evictIdleClients will purge or retain cache state based on clock adjustments instead of real inactivity. If we need wall-clock observability for last_access_time, we should keep TTL comparisons on steady_clock and store a separate wall-clock timestamp for reporting.
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 sizes18 object files changed (+82.44 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 units402 translation units recompiled, 3642 s compile time in total, 402 of them have a recent master baseline. |
|
📊 Cloud Performance Report ✅ AI verdict: This is a distributed-cache and filesystem-cache refactor: it moves read_through/write_through_distributed_cache from per-query to server-level switches (defaults unchanged, effective values preserved) and adjusts covering-segment shrink handling plus idle-client TTL bookkeeping. None of that touches the join, scan, or aggregation execution paths that TPCH Q7 and Q17 exercise, so the two flagged regressions (Q7 +17.9%, Q17 +59.4%) cannot plausibly be caused by this change — Q17's measurements were also very noisy. Both have been downgraded to not_sure as run-to-run variance rather than real PR effects. clickbench🟢 No significant changes tpch_adapted_1_officialFlagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
The entries for `distributed_cache_client_id`,
`read_through_distributed_cache`, `write_through_distributed_cache`,
`force_read_through_distributed_cache` and
`force_write_through_distributed_cache` were added to the `26.8` block of
`SettingsChangesHistory.cpp`, but `master` is already at `26.9`, so the
`settings_changes_history` style check failed:
Session setting 'distributed_cache_client_id' must be recorded in the '26.9' block
...
Move them into a new `26.9` block.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| {"force_read_through_distributed_cache", "auto", "auto", "New setting overriding the server setting `read_through_distributed_cache` for a single query."}, | ||
| {"force_write_through_distributed_cache", "auto", "auto", "New setting overriding the server setting `write_through_distributed_cache` for a single query."}, |
There was a problem hiding this comment.
compatibility will not restore the pre-26.9 query default here. SettingsImpl::applyCompatibilitySetting skips obsolete settings entirely (src/Core/Settings.cpp:9520), so the read_through_distributed_cache / write_through_distributed_cache history entries above never apply, and the new force_* settings keep previous_value = auto. With read_through_distributed_cache=1 in the server config, a query running with compatibility='26.8' still resolves resolveReadThroughDistributedCache / resolveWriteThroughDistributedCache to true, even though before 26.9 the per-query default was always false. These force_* entries need a pre-26.9 value that recreates the old default (false), otherwise the compatibility contract is broken.
…names `master` already carries the same work, naming the server-level switches `enable_read_through_distributed_cache` and `enable_write_through_distributed_cache` (see f381272). Resolve every conflict in favour of those names, and follow through on the parts that merged cleanly but still referenced the old ones: - `programs/server/Server.cpp`: the `extern` declarations and the `new_server_settings[...]` lookups in the config-reload handler now use the `enable_*` names. - `src/Core/SettingsChangesHistory.cpp`: dropped our five entries, the `26.9` block on `master` already records all of them, with wording that refers to the `enable_*` server settings. - `src/Core/ServerSettings.cpp`: dropped the `settings_from_profile_allowlist` addition. It listed the pre-rename names, which no server setting has any more, so it could never fire; and the history entry on `master` states that the old setting is ignored as a profile setting. What remains on top of `master` is the part not covered there: the `Buffer`/background context reset of the `force_*` overrides, the `BuzzHouse` setting list, and the filesystem cache usage changes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`force_read_through_distributed_cache` and `force_write_through_distributed_cache` were inserted before `force_distinct_partitions_independently`, breaking the alphabetical order of `serverSettings`. Move them after it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Brings over the FileCache reservation/eviction locking work: the split cache guard, the reduced state-lock cost on the reservation path, the dynamic-resize locking and its restore path, and the removal of the per-user usage consistency check from the hot path. `CacheUsage::update` is now defined inline, so `CacheUsage.h` no longer needs an out-of-line definition - this is the only change to the set of members declared but not defined in the header. `OvercommitFileCachePriority` is untouched: every reference to it stays behind the existing `ENABLE_DISTRIBUTED_CACHE` / `CLICKHOUSE_CLOUD` guards, and the count of references drops from 10 to 7 because the new `CacheUsage.h` no longer names it in comments. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Workflow [PR]
Sync PR [sync-upstream/pr/115630]
Version info
26.9.1.217(included in26.9and later)