Repository navigation
Fix flaky test_named_collections_encrypted2/test_zk_node_lifecycle - #105175
nikitamikhaylov merged 1 commit into
Conversation
|
Pre-PR validation gate (per worker policy, session
|
|
cc @alexey-milovidov — could you review? This is the fix for the |
|
Workflow [PR], commit [2ccdf22] Summary: ✅ AI ReviewSummaryThis PR makes Final VerdictStatus: ✅ Approve |
The test issues `CREATE NAMED COLLECTION zk_test` against the ClickHouse server (ZooKeeper session A) and then immediately calls `kazoo.get_children` on a separate kazoo client (ZooKeeper session B). The two sessions may be connected to different nodes of the ZK ensemble. Even though `ZooKeeper::createOrUpdate` on the server side is synchronous, the kazoo session can still see a stale view for a short window — normally sub-millisecond, but amplified under TSan and MSan slowdowns. The same race applies in the symmetric `DROP` case. Observed twice on master CI: - PR ClickHouse#101757 Integration tests (amd_tsan, 4/6) on 2026-05-16 - PR ClickHouse#102031 Integration tests (amd_msan, 6/6) on 2026-04-10 Both with `AssertionError: assert 'zk_test.sql' in []` at test.py:529. Fix: add `wait_zk_child_exists` and `wait_zk_child_absent` polling helpers (matching the existing `wait_exists` / `wait_not_exists` pattern, 10s timeout, 0.3s sleep) and use them in `test_zk_node_lifecycle` in place of the single-shot `get_children` membership checks. The assertions still verify the same invariant — ZK node appears after `CREATE`, disappears after `DROP` — just with bounded retry to tolerate cross-session replication lag. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102031&sha=169ea923b985fa66060e440b34cf2a908049afa4&name_0=PR&name_1=Integration%20tests%20%28amd_msan%2C%206%2F6%29 Related PR: ClickHouse#102031
a81003f to
2ccdf22
Compare
|
Rebased onto current master (fc73f46) and re-triggered CI. The branch had gone stale (last run 2026-05-17). On the prior run every Integration tests variant passed (amd_binary_excluded_from_llvm, amd_msan 6/6, amd_tsan 6/6, amd_asan_ubsan, amd_llvm_coverage, arm_binary) including the previously-flaky test_zk_node_lifecycle. The only red check was Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel), which is a broadly flaky coverage job unrelated to this integration-test-only change (fails across 5-17 unrelated PRs daily in CIDB). This is a test-only fix (one file, +34/-2): bounded ZK polling to tolerate cross-session replication lag in test_named_collections_encrypted2. The test remains chronically flaky on master (38 PRs / 81 failures in 90d) without it. Session cron:clickhouse-worker-slot-6:20260611-015300 |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 500 line(s), 46 function(s) across 127 file(s) · Details Top files
|
The integration test
test_named_collections_encrypted2/test.py::test_zk_node_lifecyclehas been flaking on sanitizer builds with:Observed twice on master CI in the last 60 days (both sanitizer shards):
Integration tests (amd_tsan, 4/6)on 2026-05-16Integration tests (amd_msan, 6/6)on 2026-04-10 (this is the failure @alexey-milovidov asked us to investigate; CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102031&sha=169ea923b985fa66060e440b34cf2a908049afa4&name_0=PR&name_1=Integration%20tests%20%28amd_msan%2C%206%2F6%29)Root cause
The test runs:
CREATE NAMED COLLECTIONis synchronous on the server side — it callsZooKeeper::createOrUpdateinNamedCollectionsMetadataStorage::ZooKeeperStorage::write, which waits for the ZK leader's response. So when the query returns to the test, the znode/named_collections_path/zk_test.sqlhas been committed.However, the test then reads via a separate kazoo client (
cluster.get_kazoo_client("zoo1")). That kazoo client is a different ZK session, potentially connected to a different node of the ZK ensemble. ZooKeeper does not guarantee cross-session linearizability between a write on session A and a subsequent read on session B if B is connected to a follower that has not yet applied the write — the follower's view is eventually consistent with the leader on the order of milliseconds. Under TSan/MSan the slowdown is large enough that this normally invisible window becomes wide enough to fail the assertion. The symmetric race exists in theDROPbranch (the kazoo client may briefly still see the znode afterwait_not_existssucceeds onnode1).Fix
Add two polling helpers next to the existing
wait_exists/wait_not_exists:wait_zk_child_exists(zk, path, child, timeout=10)wait_zk_child_absent(zk, path, child, timeout=10)Both follow the existing pattern (10 s budget, 0.3 s poll, exception-tolerant).
test_zk_node_lifecycleis updated to use them in place of the single-shotget_childrenmembership checks. The test still asserts the same invariant — the znode appears afterCREATE NAMED COLLECTIONand disappears afterDROP NAMED COLLECTION— but now tolerates up to 10 s of cross-session replication lag.The change is strictly additive: when the underlying write IS already visible to the kazoo session (the common case), the first poll iteration returns immediately, so this introduces no measurable runtime overhead. If the server fails to write/remove the znode at all, the 10 s timeout still expires and the assertion fails as before.
cc @alexey-milovidov
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.6.1.683