Repository navigation
Fix flaky test_default_session_user config-reload tests racing with the background config reloader - #116109
Conversation
… reloader test_config_reload_prometheus_handlers_switch_to_fixed_user failed twice on master on Integration tests (amd_msan, 1/8) with the endpoint's <default_session_user> restart line missing from the server log. A listener's restart decision in updateServers compares the incoming config against the config recorded by the previous reload. SYSTEM RELOAD CONFIG is not the only reloader: the background ConfigReloader polls every config_reload_interval_ms (default 2000 ms) through the same updater, keyed on the config file's mtime, which replace_in_config's sed -i bumps. When a poller tick lands between a test's config edit and its explicit reload, the poller consumes the difference and records the edited config; the explicit reload then compares an edited config against an edited config, decides nothing changed, and logs nothing. In the failing run the three "will reload" lines carry no query id and run on the poller thread 352 ms before the test's SYSTEM RELOAD CONFIG, which logged no listener lines at all. The <default_session_user> variant is lost rather than merely late, because it is gated on the handler set consuming the setting, which the same edit removes. Pin config_reload_interval_ms to one hour for the module's three instances, so SYSTEM RELOAD CONFIG is the only reloader and the one-edit-set-to-one-reload assumption these tests already make actually holds. This follows the existing idiom in test_zookeeper_connection_log and test_shard_names. The same change also repairs three "assert not contains_in_log" sites, which were passing vacuously under this race: a negative assertion is satisfied whenever the poller already consumed the edit, so it failed silently open. No polling scheme could fix those, only removing the competing reloader. Forcing the race (a 50 ms poller and a 1 s gap between the two edits) reproduces the exact CI assertion 20 times out of 20, with the line absent from the whole server log. With this change under the same forcing, 20 of 20 pass and the line appears attributed to the reload query's own query id. The full module is 29 of 29 green. Related: ClickHouse#110179
Nothing observed the pinned interval, so dropping the config fragment from an instance's main_configs, deleting the file, or mistyping the value would silently fall back to the 2000 ms default and leave the module green most of the time, since the race only fires when a poller tick happens to land in the narrow window between a test's config edit and its explicit reload. A revert that stays green is exactly what a regression test has to prevent. Assert in started_cluster, which every test in the module goes through, that each of the three instances reports config_reload_interval_ms = 3600000, using the system.server_settings form that test_config_reloader_interval already uses. The value is published on the initial config load, before any reload is needed, so the read is a plain point-in-time query with no polling and no log window to match against. The assertion is the positive form on purpose. An "absence of 2000ms" oracle would be permanently false, because the users config reloader logs its own "Config reload interval set to 2000ms" line on the same server. Removing the fragment from node_reject alone makes the fixture fail with "assert '2000' == '3600000'", so the assertion discriminates per instance and reads the real default rather than erroring out. Restored, the module is 29 of 29 green.
Internal second-model review (click to expand)Independent cold review of the resulting diff plus a second-model gate pass, adjudicated against the
Also checked and clean: the root cause was re-derived from source independently ( Session ids: cron:clickhouse-review-slot-9:20260824-114600, cron:clickhouse-review-slot-8:20260824-125100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-8:20260824-125100 |
|
Workflow [PR], commit [4b42e04] Summary: ✅ AI ReviewSummaryThis PR pins Final Verdict
|
|
cc @azat, could you review this? Test-only: the module's tests assume |
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. Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger - 4b42e04CI fully finished and no check failed, so no ledger row is owed. Gate (a) no check queued/in_progress (182 runs, 175 unique) - gate (b) Finish Workflow Corroboration: praktika Session id: cron:our-pr-ci-monitor:20260824-180000 |
073712a
Backport #116109 to 26.8: Fix flaky test_default_session_user config-reload tests racing with the background config reloader
…er config-reload tests racing with the background config reloader
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
test_default_session_user/test.py::test_config_reload_prometheus_handlers_switch_to_fixed_userfailed twice on master today on
Integration tests (amd_msan, 1/8), and is clean on every other checkvariant that ran it (master, 30 days: 60 OK, 2 FAIL). No related open issue. The test landed with #110179.
CI report
Root cause. A listener's restart decision in
updateServerscompares the incoming config againstthe config recorded by the previous reload.
SYSTEM RELOAD CONFIGis not the only reloader: thebackground
ConfigReloaderpolls everyconfig_reload_interval_ms(default 2000 ms) and detectschange by config-file mtime, which
replace_in_config'ssed -ibumps. A poller tick landing betweena test's edit and its explicit reload consumes the difference, so the test's own reload compares an
edited config against an edited config and logs nothing. In the failing run a poller reload started
352 ms before the test's own reload and emitted the three
will reloadlines with no query id; thetest's
SYSTEM RELOAD CONFIGthen logged no listener lines at all.Change. Pin
config_reload_interval_msto one hour for the module's three instances, soSYSTEM RELOAD CONFIGis the only reloader and the one-edit-set-to-one-reload assumption these testsalready make actually holds. This follows the existing idiom in
test_zookeeper_connection_logandtest_shard_names. Test-only: no assertion changed, no test removed, no server default altered.This also repairs three
assert not contains_in_logsites that were passing vacuously: a negativeassertion is satisfied whenever the poller already consumed the edit, so it failed silently open. No
polling scheme could fix those; only removing the competing reloader can.
Validation. Forcing the race (50 ms poller, 1 s gap between the two edits) reproduces the exact CI
assertion 20/20, with the line absent from the whole server log. With the fix under the same forcing,
20/20 pass and the line appears with the reload query's own query id. Full module 29/29 green.
Workflow [PR]
Sync PR [sync-upstream/pr/116109]
Version info
26.9.1.40(included in26.9and later)26.8.3.20