Repository navigation
Fix flaky test_replicated_users grant/rename under async replication - #111239
Conversation
test_grant_revoke_replicated read the grant back from node2 with a bare, un-retried query (the only cross-replica read in the file without a retry). ReplicatedAccessStorage replicates the grant to node2 asynchronously, so a fast read can observe stale state and return empty grants. When that assert failed, the test aborted before dropping theuser2, leaking the user into the next test, whose ALTER USER ... RENAME TO theuser2 then hit the leftover entity with ACCESS_ENTITY_ALREADY_EXISTS. So both amd_tsan failures reported on ClickHouse#111007 stem from this one test bug, not a server bug. Read the grant back with assert_eq_with_retry, and drop theuser2 / restore the profile in a finally block so nothing can leak into later tests. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-4:20260721-125300 |
Internal second-model review (1 finding, adjudicated)An independent second model reviewed the diff. Findings and dispositions: ❌ Blockers
|
|
cc @pufit — could you review this? It fixes two flaky |
|
Workflow [PR], commit [ed797f3] Summary: ✅ AI ReviewSummaryThe PR updates Final VerdictStatus: ✅ Approve |
CI finish ledger — ed797f3CI is fully finished on this head and there are no failures: 174 check-runs, 0 incomplete, 45 jobs ran, including the whole integration matrix this fix is about: Nothing to attribute, so there is no owner column to fill. For the record on timing rather than on this result: the workflow only started today, after the Session id: cron:our-pr-ci-monitor:20260807-200000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes two flaky failures in
test_replicated_usersseen underamd_tsan, reported by @ alexey-milovidov on #111007:test_grant_revoke_replicated[With_ignored_on_cluster]— emptySHOW GRANTSright after a replicatedGRANT.test_rename_replicated[USER]—ACCESS_ENTITY_ALREADY_EXISTSonALTER USER ... RENAME.Both trace to a single test bug, not a server bug.
Root cause.
test_grant_revoke_replicatedreads the grant back fromnode2at line 167 with a bare, un-retriednode2.query("SHOW GRANTS FOR theuser2"). It is the only cross-replica read in the file without a retry; every other one already usesquery_with_retry/assert_eq_with_retry.ReplicatedAccessStoragepropagates the write tonode2asynchronously, so a fast read can observe stale state. In the failing runnode2was read 265 ms after thenode1grant and returned empty.The second failure is a cascade of the first: when line 167 fails, the test aborts before its
DROP USER theuser2, leakingtheuser2; the next test then doesALTER USER theuser RENAME TO theuser2and correctly hits the leftover entity (all 20 retries fail identically; the server-side collision check is behaving as intended). CI history confirms the two tests fail together in the same commit, never independently.Fix (test only):
assert_eq_with_retryso it tolerates the replication window.theuser2create/drop intry/finallyso the user and the profile config are always restored, even on an earlier assertion failure, so nothing can leak into later tests.Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111007&sha=472b806e1820703eafeb6fb2dcd4e928bb482baf&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29
Verification: the two failing tests plus their siblings pass in the integration harness (7 passed, no retries). Reverting to the bare read reproduces the stale-
node2read against a local 2-node replicated-access cluster.Version info
26.8.1.1003(included in26.8and later)