Repository navigation
Stop test_refreshable_mv_no_multi_read from clamping its Keeper sessions to 10 s - #112508
alexey-milovidov merged 3 commits into
Conversation
…ons to 10 s Cleanup DDL in this suite fails with a raw "Code: 999. Coordination error: Connection loss, path /clickhouse/rdbN/max_log_ptr" on Integration tests (amd_tsan, 4/6): 6 rows over 4 tests and 4 unrelated PRs plus a master hit, all on 2026-07-29. In test_refreshable_mv_missing_flags_shutdown_clears_running_lock the failing statement is the load-bearing DETACH TABLE ... PERMANENTLY SYNC, so the run aborts before that test's three Keeper assertions execute and the regression coverage is silently lost. The suite pinned the server's maximum session timeout to the same value as its minimum, which clamps every session to 10 s. keeper_server.coordination_settings.session_timeout_ms is read as max_session_timeout while min_session_timeout defaults to DEFAULT_MIN_SESSION_TIMEOUT_MS = 10000 (KeeperTCPHandler.cpp:253-254). The <zookeeper> blocks set no client timeout, so the client requests DEFAULT_SESSION_TIMEOUT_MS = 30000 and the negotiation computes min(max(30000, 10000), 10000) = 10000 (KeeperTCPHandler.cpp:436-439); with max == min the clamp is unconditional. This node's Keeper is embedded in the same process and the file restarts it 13 times, so on a loaded TSAN host a quiet period past 10 s finalizes the session mid-DDL. Raise that cap to 30000 in all three keeper configs so sessions negotiate the same 30 s every other integration test gets. What this buys is wall-clock stall tolerance, 10 s to 30 s. It is not extra heartbeats: the heartbeat interval is session_timeout_ms / 3 (ZooKeeperImpl.cpp:876) and the idle deadline is the full session_timeout_ms (:1050), so the missed-heartbeat budget is invariantly 3 at any value. Validated by measuring the negotiated timeout two independent ways on each of the three configs. The server-side cons four-letter command, whose to= field is KeeperTCPHandler::session_timeout (:924), reports to=10000 before and to=30000 after; the client heartbeat cadence in the server log goes 3.333 s to 10.0 s. Reverting one config alone returns only that config to 10000, so each file is load-bearing. The suite passes 9/9. The timing race itself is not reproducible locally, so this removes a self-inflicted 10-second window rather than guaranteeing a Keeper session can never drop. Note that system.zookeeper_connection.session_timeout_ms cannot be used to observe this: it returns the zkutil::ZooKeeper wrapper's args copy (ZooKeeper.h:732), while receiveHandshake overwrites only the Coordination::ZooKeeper impl's separate copy (ZooKeeperImpl.h:265), so it reports the client's request and is blind to the clamp. No test logic changes and no test in this suite expires a session on purpose, so the extra headroom cannot alter what any of them measures.
The previous commit raised the server's max session-timeout cap from 10000 to 30000 in the suite's three Keeper configs, because the cap was equal to the server's default minimum and therefore clamped every client session to 10 s unconditionally. Nothing in the suite read that negotiated value, though: every test asserts refresh-view behaviour, so reverting any single config back to 10000 left all nine tests green and the invariant rested on a by-hand measurement instead of on CI. Add a read-only helper that queries the server-side `cons` four-letter command after each config swap and asserts every established session reports to=30000, called once per edited config file. `cons` is in the default four-letter allow list, so no config change is needed, and asserting its `to=` field follows test_keeper_four_word_command. The command answers on its own connection as well, and that connection never completed a handshake: its session id is still the -1 initializer, which passes the `session_id != 0` guard in dumpStats while `session_timeout` was never assigned for it, so it reports to=0. Filter it out and assert the list of real sessions is non-empty, otherwise an all-filtered parse would pass silently. Verified per config file: reverting exactly one config to 10000 fails only this new assertion, reporting the observed 10000, while the pre-existing assertions in the same test still pass. The whole module passes 9/9 and the three calls cost about 6 ms in total. Co-Authored-By: Claude Fable 5 <[email protected]>
…timeout The negotiated-timeout guard added in the previous round read `cons` exactly once and treated an empty session list as a hard failure. At the first call site the node has no Replicated database yet, so the only creator of the server's own Keeper session is DDLWorker startup, which is scheduled as an AsyncLoader job that nothing waits for (Context::setDDLWorker) - `restart_clickhouse()` returns as soon as a query answers, which does not imply the session exists. The two later call sites are unaffected because DatabaseReplicated::beforeLoadingMetadata connects synchronously in the non-async prologue of TablesLoader::loadTablesAsync, long before the server accepts connections. Only the session's existence is polled (30 s budget, 0.5 s interval). The timeout value itself is never retried, so a clamped session still fails on the first read with the observed value, and each of the three config edits stays separately load-bearing. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model across three rounds (engine: codex; 2 findings
Severity: ❌ blocker / Notes on the two blockersA mechanical trap was worth catching for finding 1: For finding 2, sites 2 and 3 are not affected: a Replicated database already exists at those The poll deliberately polls only the session's existence, so a clamped session still fails on the Checked and deliberately unchanged
Reported honestlyThe Session id: cron:clickhouse-review-slot-48:20260730-013900 |
Pre-PR validation gate (a-i)
Notes. Integration tests are not subject to Session id: cron:clickhouse-review-slot-48:20260730-013900 |
|
cc @al13n321, could you review this? The refreshable-MV Keeper suite set its embedded Keeper's maximum session timeout to the same value as the default minimum, so every session was clamped to 10 s and a stall past that dropped the session under the cleanup DDL; the negotiated timeout is now asserted in-tree, once per config file. |
|
Workflow [PR], commit [0785e29] Summary: ✅ AI ReviewSummaryThis PR raises the embedded Keeper max session timeout in the three Final Verdict✅ No findings. |
CI finish ledger - 0785e29Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task No failures on this commit. All 174 check-runs completed with zero non-success conclusions Session id: cron:our-pr-ci-monitor:20260730-163853 |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Doubtful but passable.
Correcting the "tracked separately" note in this PR's description, and closing it outI investigated the follow-up this PR's description points at, and the note itself is wrong in two ways. Correcting it here so nobody chases it. The note says: " 1. That override is unreachable. 2. There is no asymmetry to restore anyway. The base honours the retries info only under The reachable site was this suite's own misconfiguration, and this PR fixed it. The genuinely unretried read is I am not opening a follow-up PR, for three reasons. Wrapping that read in If absorbing it in the server is wanted, the shape would have to be opt-in rather than on by default, and that is a policy call for the engine owners. |
Related: #107042
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Cleanup DDL in
test_refreshable_mv_no_multi_readfails with a rawCode: 999. Coordination error: Connection loss, path /clickhouse/rdbN/max_log_ptronIntegration tests (amd_tsan, 4/6): 6 rows over 4 tests and 4 unrelated PRs plus a master hit, all on 2026-07-29. In..._missing_flags_shutdown_clears_running_lockthat statement is the load-bearingDETACH TABLE ... PERMANENTLY SYNC, so the run aborts before the assertions and the coverage is silently lost.Root cause: the suite pinned the server's maximum session timeout to the same value as its minimum, clamping every session to 10 s.
session_timeout_msis read asmax_session_timeoutwhilemin_session_timeoutdefaults to 10000 (KeeperTCPHandler.cpp:253-254); the<zookeeper>blocks set no client timeout, so the client requests 30000 and negotiation yieldsmin(max(30000, 10000), 10000)(:436-439). This node's Keeper is embedded in the same process and the file restarts it 13 times, so on a loaded TSAN host a quiet period past 10 s drops the session mid-DDL.Raising that cap to 30000 in all three keeper configs makes sessions negotiate the client default instead, buying stall tolerance of 10 s to 30 s. It is not extra heartbeats: the interval is
session_timeout_ms / 3, so the budget is 3 either way. No existing assertion or failpoint changes. Only 9 of the 235coordination_settingsblocks undertests/integrationthat set it share this shape; elsewhere a co-located client mirrors the cap.The invariant is pinned in-tree rather than measured by hand: after each config swap the suite reads the server-side
consfour-letter command and asserts the negotiated timeout is 30000, once per edited config file. Reverting any single config to 10000 fails that assertion with the observed value, so a partial fix or a future re-lowering is caught by CI. The module passes 9/9.Tracked separately:
DatabaseReplicatedDDLWorker::enqueueQuerydiscards itsZooKeeperRetriesInfo(DatabaseReplicatedWorker.cpp:337-341) where the base honours it.Master run: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=e0e5e04a027ed740ab3756d4853fb6d21126c077&name_0=MasterCI&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29
Version info
26.8.1.481(included in26.8and later)