Skip to content

Make getServerSetting return live values for runtime-changeable settings - #105172

Merged
alexey-milovidov merged 10 commits into
masterfrom
fix-getServerSetting-live-values
Jun 7, 2026
Merged

alexey-milovidov merged 10 commits into
masterfrom
fix-getServerSetting-live-values

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 17, 2026 •

Copy link
Copy Markdown
Member

For server settings whose effective value is computed at startup or adjusted on config reload (memory limits, cache sizes, thread pool sizes, etc.), system.server_settings already reports the value the component is actually using, while getServerSetting returned only the raw value loaded from the config — typically 0 or some other placeholder. For example:

:) SELECT getServerSetting('max_server_memory_usage');
0
:) SELECT value FROM system.server_settings WHERE name = 'max_server_memory_usage';
182155769856

Extract the list of runtime overrides out of dumpToSystemServerSettingsColumns into a shared helper, expose it via ServerSettings::tryGetLiveValueAsString, and consult it from getServerSetting so both surfaces agree.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix getServerSetting to return the live effective value for runtime-changeable server settings (such as max_server_memory_usage, mark_cache_size, max_concurrent_queries, thread pool sizes, etc.), matching what system.server_settings reports.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.6.1.468

For settings such as `max_server_memory_usage` whose effective value is
computed at startup or adjusted on config reload (memory limits, cache
sizes, thread pool sizes, etc.), `system.server_settings` already
reports the value the component is actually using, while
`getServerSetting` reported only the raw value loaded from the config
- typically `0` or some other placeholder.

Extract the list of runtime overrides out of
`dumpToSystemServerSettingsColumns` into a shared helper, expose it via
`ServerSettings::tryGetLiveValueAsString`, and consult it from
`getServerSetting` so both surfaces agree.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ea7d7f0]

Summary: ✅


AI Review

Summary

This PR makes getServerSetting consult the same live-value projection used by system.server_settings for runtime-adjusted and dynamically derived server settings. I re-checked the current code, the PR diff, CI discussion, and all prior review threads; the earlier keeper_hosts disagreement is addressed by moving that projection into the shared helper, and I found no remaining blocker or major issue.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label May 17, 2026
Comment thread src/Core/ServerSettings.cpp Resolved
The changeable-settings map is keyed by canonical names, but
`getServerSetting` accepts path-style aliases such as
`query_cache.max_size_in_bytes` (alias for `query_cache_max_size_in_bytes`).
Without resolving the alias first, the lookup missed the live value and
the function silently fell back to the stale config value.

Run `name` through `ServerSettingsTraits::resolveName` before consulting
the map, and add a test that exercises a path alias.
Comment thread src/Core/ServerSettings.cpp Resolved
alexey-milovidov and others added 2 commits May 20, 2026 17:04
…_values`

The earlier follow-up [`7082d164f86`](7082d164f86) tried to support
path-style names (e.g. `query_cache.max_size_in_bytes`) in
`getServerSetting` by routing the lookup through
`ServerSettingsTraits::resolveName`. That does not actually help:
`LIST_OF_SERVER_SETTINGS_WITH_PATH` expands only `DECLARE(...)` entries,
so path strings are never inserted into `aliases_to_settings` and
`resolveName` returns the path verbatim. The follow-up test
`getServerSetting('query_cache.max_size_in_bytes')` therefore throws
`UNKNOWN_SETTING` from `BaseSettings::set`/`get` (see the Fast-test
failure at
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105172&sha=7592dd7aeb3033734c7030b1fa315a1a7aac75f2&name_0=PR&name_1=Fast%20test).

Revert the no-op `resolveName` call and drop the broken alias assertion
so this PR stays focused on its stated goal: returning live values for
runtime-changeable settings. Adding path-as-alias resolution is a
separate, cross-cutting change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The `collectChangeableServerSettings` map hardcoded the value of
`s3queue_disable_streaming` to `"0"`, which made `system.server_settings`
display a stale value and now also makes `getServerSetting` (which routes
through `ServerSettings::tryGetLiveValueAsString`) return a stale value
that ignores the most recent config reload.

Replace the hardcoded `"0"` with the actual live value read back from the
global `ServerSettings`, which is kept up to date by `Context::setS3QueueDisableStreaming`
on every `SYSTEM RELOAD CONFIG`.

This fixes `test_storage_s3_queue/test_5.py::test_disable_streaming` and
the tests that cascade from it (`test_mv_settings`, `test_persistent_processing`,
`test_metadata_cache_exact_size_tracking`, `test_detach_attach_table`) which
all exercise `SELECT getServerSetting('s3queue_disable_streaming')` after a
`SYSTEM RELOAD CONFIG`.
…g-live-values

# Conflicts:
#	src/Core/ServerSettings.cpp
/// In that case the live value held by the component diverges from the value stored in `ServerSettings`,
/// which only reflects what was last loaded from the config. `system.server_settings` already returns
/// the live value for such settings - mirror that behaviour here.
if (auto live = server_settings.tryGetLiveValueAsString(global_context, setting_name))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a hack. Why don't we update ServerSettings when updating configuration?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is deliberately matching the model that system.server_settings already uses. Updating ServerSettings during reload would be a broader ownership change: many values in this list are post-processed or component-owned live state (total_memory_tracker, caches, pools, throttlers), so making ServerSettings authoritative would require every reload path to write back the effective value after clamping or applying it, not just the raw config value.

That may be a cleaner long-term direction, but it is larger than this scoped fix. Sharing the existing live-value projection keeps getServerSetting consistent with system.server_settings without changing the current split between raw config state in ServerSettings and effective state in the components.

Comment thread src/Core/ServerSettings.cpp Resolved
`system.server_settings` reports `keeper_hosts` (derived from the
`<zookeeper>` config) via a special-case overlay in
`StorageSystemServerSettings::fillData`, separate from the
`collectChangeableServerSettings` helper that `getServerSetting` now
consults. As a result `getServerSetting('keeper_hosts')` returned the
raw empty default while `system.server_settings` returned the live
endpoints, breaking the "both surfaces agree" contract for this
setting.

Move the `keeper_hosts` projection into `collectChangeableServerSettings`
so both surfaces share a single source of truth, and drop the duplicated
overlay from `fillData`. Extend the regression test to compare
`getServerSetting('keeper_hosts')` with `system.server_settings`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Pushed ea7d7f09d98 addressing the remaining bot finding about keeper_hosts.

What changed: keeper_hosts was the one dynamic value system.server_settings computed outside the shared helper (a special-case overlay in StorageSystemServerSettings::fillData), so getServerSetting('keeper_hosts') fell through to the empty default and the two surfaces disagreed. I moved the projection into collectChangeableServerSettings (single source of truth) and removed the duplicated overlay from fillData, plus extended the 04241 regression to compare the two surfaces directly.

Verification: built clean and ran on a single-node embedded-Keeper server — getServerSetting('keeper_hosts') and system.server_settings.value both return the configured endpoint; all five 04241 assertions pass. The existing 03633 keeper test is unaffected (the value column is produced identically). Side effect: system.server_settings is now marginally more accurate for this row (changed = 0, since keeper_hosts is never written in config.xml; changeable_without_restart = Yes, since it follows the config on reload).

I left the "why not update ServerSettings on config reload" thread open — that's a broader ownership question (caches/pools/throttlers hold component-owned live state) and your call on direction. CI was green prior to this push.

Resolved the keeper_hosts thread.

@clickhouse-gh

clickhouse-gh Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.50% 84.40% -0.10%
Functions 92.40% 92.40% +0.00%
Branches 77.10% 77.00% -0.10%

Changed lines: Changed C/C++ lines covered by tests: 48/48 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 7, 2026
@alexey-milovidov alexey-milovidov self-assigned this Jun 7, 2026
Merged via the queue into master with commit ba56a04 Jun 7, 2026
166 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-getServerSetting-live-values branch June 7, 2026 02:51
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 7, 2026
@Algunenano

Copy link
Copy Markdown
Member

A race condition was found: #106902. Let's revert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants