Repository navigation
Revert "Revert "Make getServerSetting return live values for runtime-changeable settings"" - #107388
Merged
alexey-milovidov merged 3 commits intoJun 13, 2026
Conversation
…changeable settings""
Contributor
|
Workflow [PR], commit [02ce0c5] Summary: ✅
AI ReviewSummaryThis PR re-applies the live-value behavior for Final VerdictStatus: ✅ Approve |
`getServerSetting` (re-introduced here) read the live value of runtime-changeable server settings by copy-constructing the whole `ServerSettings` struct from the reference returned by `Context::getServerSettings`, without any synchronization. Meanwhile the config reloader mutates a few fields of the shared `server_settings` at runtime (e.g. `setS3QueueDisableStreaming`, `setMessageQueueDisableInsertion`), holding `shared->mutex`. The unsynchronized full-struct copy in the reader raced with those writers, which `ThreadSanitizer` reported as a data race in `__tsan_memcpy`. This is why the original change was reverted. Add `Context::getServerSettingsCopy`, which takes a consistent snapshot of `shared->server_settings` under `shared->mutex` (matching the lock the writers already take), and route the racy reads through it: - `getServerSetting` now operates on a locked snapshot instead of copying the live reference. - `collectChangeableServerSettings` reads `s3queue_disable_streaming` (a runtime-mutable field) through the locked copy instead of the bare reference. Closes: #106902 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…mit drift
The flaky check failed on the `max_server_memory_usage` assertion: the test
compared `getServerSetting('max_server_memory_usage')` against the value in
`system.server_settings` for exact equality, but both read
`total_memory_tracker.getHardLimit()`, which is auto-adjusted at runtime (based
on cgroup/RAM observations). The two reads happen at different moments, so the
limit can change between them and the equality flakes.
Assert instead that `getServerSetting('max_server_memory_usage')` is non-zero,
which is what the fix actually changed (it used to return the raw config value
`0`). The remaining settings compared for exact equality
(`max_concurrent_queries`, `mark_cache_size`, `mark_cache_policy`, `keeper_hosts`)
are config-driven and stable during the test.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107388&sha=faddff6cd96c6274c16cc8c0ad75ab6a91a2c90e&name_0=PR
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 45/45 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 4 line(s) · Uncovered code |
alexey-milovidov
deleted the
revert-106930-revert-105172-fix-getServerSetting-live-values
branch
June 13, 2026 22:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-applies #105172 ("Make
getServerSettingreturn live values for runtime-changeable settings"), which was reverted by #106930 because of a data race.getServerSettingread the live value of runtime-changeable server settings by copy-constructing the wholeServerSettingsstruct from the reference returned byContext::getServerSettings, without any synchronization. Meanwhile the config reloader mutates a few fields of the sharedserver_settingsat runtime (e.g.setS3QueueDisableStreaming,setMessageQueueDisableInsertion) while holdingshared->mutex. The unsynchronized full-struct copy in the reader raced with those writers, whichThreadSanitizerreported as a data race in__tsan_memcpy. This was the root cause of the revert.This PR fixes the root cause:
Context::getServerSettingsCopy, which takes a consistent snapshot ofshared->server_settingsundershared->mutex(the same lock the writers already take).getServerSettingnow operates on a locked snapshot instead of copying the live reference.collectChangeableServerSettingsreads the runtime-mutables3queue_disable_streamingfield through the locked copy instead of the bare reference.04241_get_server_setting_live_valuestest robust: themax_server_memory_usagevalue is auto-adjusted at runtime, so it is now asserted to be non-zero instead of compared for exact equality (which raced with the runtime adjustment).Closes: #106902
Related: #105172
Related: #106930
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
getServerSettingto return the live effective value for runtime-changeable server settings (such asmax_server_memory_usage,mark_cache_size,max_concurrent_queries, thread pool sizes, etc.), matching whatsystem.server_settingsreports.Documentation entry for user-facing changes
Version info
26.6.1.770