Repository navigation
Pin five stateless tests a Replicated database cannot enforce - #112993
PedroTadim merged 5 commits into
Conversation
These five tests fail deterministically (Failed 3 of 3 reruns) on the DBReplicated flavours and are then force-set to OK by the llvm-coverage whitewash, so today they assert a deny path that silently allows and catch nothing at all on those configurations. Two distinct causes. Four access tests (04318_remote_storage_engine_access, 04401_remote_storage_engine_restore_access, 04401_url_engine_s3_dispatch, 04489_remote_storage_engine_restore_tf_access) assert checks implemented inside storage construction (StorageDistributed.cpp, StorageURL.cpp). On a Replicated database InterpreterCreateQuery returns tryEnqueueReplicatedDDL, which performs no checkAccess, and the entry is executed by a worker whose context has no user: DDLTask::makeQueryContext only calls setUser when distributed_ddl_use_initial_user_and_roles is enabled and initiator_user is set, and only the ON CLUSTER path populates initiator_user. Context::getAccess then computes full_access = !user_id, so those in-storage checks short-circuit to allow. Observed in the server log: the RESTORE arrives as the restricted user, but the CREATE TABLE ... ENGINE = Remote(...) it produces executes as (from 0.0.0.0:0, user: , initial_query_id: ...) and succeeds where the test requires rejection. The signature that this is one cause and not three: in 04401_url_engine_s3_dispatch the table-function source check still passes, because a table function is analyzed on the initiator, while both engine checks flip to NOT DENIED. This is open issue ClickHouse#111561, so each of these four comments names it and git grep 111561 tests/ finds every pin when it is resolved. 02440_mutations_finalization pauses the merge-selecting task with a failpoint, but SYSTEM ENABLE FAILPOINT is a process-local call and the helper macro appends auto_{shard}, so the table is created once per shard and the untouched shard's scheduler finishes the mutation the test expects to stay pending. That is a harness assumption rather than a defect, so its comment cites no issue. No assertion is weakened, inverted or removed and no reference file changes. The tag reaches three configurations (replicated-database, cloud, shared-catalog), all of which are replicated or shared-catalog database environments subject to the same gap. Coverage is retained everywhere else: 250/250 green over 50 randomized runs on the default flavour, 250/250 skipped on the affected one. The engine fix is deliberately not attempted here. ClickHouse#111561 is parked on an owner-level decision, since the authorization channel is either one host (rights-dependent results then diverge per replica), or all hosts (which is distributed_ddl_use_initial_user_and_roles, off by default), or refusing to execute. A write-up with three options is already posted there. 04541_create_as_select_table_scoped_insert_grant and 04418_create_table_as_select_subquery_access are left failing on purpose as that issue's live evidence and are untouched. Same instrument as ClickHouse#112862.
The `no-replicated-database` comment added for
`02440_mutations_finalization` in the previous commit named the wrong host.
It attributed the mutation to a scheduler on the cluster's other shard.
That host is the one that provably cannot affect this test, and the host that
can was left unnamed. The tag, the assertions and every reference file are
unchanged; this corrects prose only.
The real mechanism. `DatabaseReplicated` appends `auto_{shard}` to the
ZooKeeper path and `auto_{replica}` to the replica name, and the functional
test cluster in `tests/config/config.d/database_replicated.xml` has a doubled
first shard: three hosts on ports 9000, 19000 and 29000, where
`ci/jobs/scripts/clickhouse_proc.py` gives 19000 `--macros.replica r2` and
29000 `--macros.shard s2`, so the hosts are `s1/r1`, `s1/r2` and `s2/r1`.
The first two therefore land on one path, `.../mut/auto_s1`, under replica
names `1auto_r1` and `1auto_r2`: one table with two replicas, not two tables.
`ReplicatedMergeTree` is multi-leader, so the second replica is a leader too
and its `mergeSelectingTask` runs unpaused, because `SYSTEM ENABLE FAILPOINT`
is a direct process-local call in `InterpreterSystemQuery` with no
`ON CLUSTER` fan-out, and the client sends every query to one endpoint. That
task assigns the mutation on the initiator's own table, and the initiator's
own queue executor, which no failpoint touches, applies it. Both failpoint
sites sit inside `mergeSelectingTask`, not in queue execution.
The other shard cannot be the cause because the assertion cannot see it:
`StorageSystemMutations::fillData` iterates the local catalog only, so a
mutation on `.../mut/auto_s2` never appears in the `system.mutations` rows
this test selects, and `SELECT * FROM mut` likewise reads the local table.
The first commit's message, and the PR description drafted with it, said these
five tests fail deterministically on the DBReplicated flavours and cited a
reproducibility-check line reading three failures of three reruns, written in a
form the harness does not use. That citation was inherited from earlier triage
notes and never re-measured. It is wrong three ways, and no tracked file
changes here: the tags,
the assertions, every reference file and the mechanism prose corrected in the
previous commit all stay exactly as they are. This commit exists to put the
correction in the history that carries the false claim, since
`.claude/CLAUDE.md` forbids amending or rebasing a branch.
What was wrong. First, the harness never emits that string:
`tests/clickhouse-test` formats `Failed {fail_count} out of {max_reruns}
reruns.`, so someone grepping CI for the quoted text finds nothing, and the
consumer regex on the same file spells `out of` too. Second, the string covers
four carriers, never `02440_mutations_finalization`, whose 6446 rerun-carrying
rows all read `Failed 0 out of 3 reruns` and whose only honest failure in 21
days is one sequential run on an unrelated pull request. Third, for the four
access tests it appears exactly once each, all four on one commit: the run on
ClickHouse#112247 that forwards the job's flags to the diagnostics rerun. Every other row
reads `Failed 0 out of 3 reruns`, which is the whitewash this branch is about.
So the sentence read as a broad standing CI signal when the evidence is one
flags-forwarded run.
What is true instead, measured over the same 21 days on the DBReplicated
checks. The divergence is present in 100% of executed runs of the four access
tests, 4513, 4513, 6772 and 4513 rows, and in 96.4% of `02440`'s, 6447 of 6685.
On the flags-forwarding run the four access tests do report `Failed 3 out of 3
reruns`. Those numbers are stronger than the retracted claim, which is why this
is a citation fix and not a change of substance.
The previous commit retracted one false CI citation and installed a replacement that overstates in a new way. The description drafted with it said the run forwarding the job's flags to the diagnostics rerun is the only one that escapes the coverage whitewash, and that every other row reports zero failures of three reruns. Both halves are false. No tracked file changes here: this commit points at the same tree as the previous one. The tags, the assertions, every reference file and the two mechanism explanations all stay exactly as they are. It exists to put the correction in the history that carries the overstatement, since `.claude/CLAUDE.md` forbids amending or rebasing a branch. What was wrong. Measured over the same 21 days on the DBReplicated checks, filtering the five carriers on a failing status, there are 19 honest failure rows across 7 commits and 5 pull requests: 108443, 109239, 109920, 112052 and 112247. The flags-forwarding run accounts for 4 of those rows and 1 of the 7 commits, so it is not the only escape. And the two-way split does not hold either: only those 4 rows carry a reproducibility-check block at all, so the remaining 15 report neither three-of-three nor zero-of-three, and the "every other row" clause has no room for the majority of the escapes. What is true instead, from one query so every figure is mutually consistent. The whitewash is dominant but not total: 26686 rows report zero failures of three reruns, while 19 surface honestly. The divergence, reported as a result difference or, for `04318_remote_storage_engine_access`, as output on standard error, covers 100% of executed runs of the four access tests, 4518, 4518, 6772 and 4518 rows, and 96.4% of `02440_mutations_finalization`'s, 6449 of 6687. The honest failures are the same divergence rather than unrelated breakage: `04318`'s carry `Code: 57` on `t_remote`, the third-create signature the local reproduction produced, the other access tests differ from their reference, and `02440`'s single row shows the predicted pending-mutation difference. The attribution of the three-of-three reruns line to the flags-forwarding run is retained, because that string does appear once per access test and only on that commit. What is retracted is the claim of exclusivity.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 4 rounds; 1 finding raised,
Severity: ❌ blocker / The final review pass found 0 findings, as did the final independent gate. Every figure in the Session id: cron:clickhouse-review-slot-49:20260802-110400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-42:20260802-040400 |
|
cc @PedroTadim, could you review this? It is the same instrument you merged in #112862, applied to the harder class: five tests whose statements succeed on a Replicated database but produce different output, four because replicated DDL is replayed with no user so the in-storage access checks no-op (open issue #111561), and one because its process-local failpoint cannot pause the second replica of the same table. |
|
Workflow [PR], commit [d4ab16c] Summary: ✅ AI ReviewSummaryThis PR adds Final Verdict
|
The file-level no-replicated-database pin was broader than the regression it works around. Issue ClickHouse#111561 invalidates only the two CREATE-time engine-grant denials: those checks live inside storage construction, which a replicated DDL runs with no user, so full_access makes them no-ops. The remaining assertions in the file are unaffected. The url('s3://...') source-grant check is a plain SELECT analysed on the initiator, which has a user, and the engine-name, reload-safety and TRUNCATE-rejection checks do not depend on access control at all. Pinning the whole file therefore dropped five live assertions, including the only stateless coverage of S3 source-grant dispatch, from the replicated, shared-catalog and cloud flavours. Move the two invalidated subcases into 04401_url_engine_s3_dispatch_engine_grant, which carries the pin and the issue link, and leave the rest of the file unpinned so it runs everywhere. The http allow case moves with them: it is the companion that keeps a denial from passing merely because the user holds no engine grant at all. Measured on a private 3-host, 2-shard replicated-database harness. Before, the whole file failed under --replicated-database with exactly the two engine lines reading NOT DENIED while s3-source-required still passed. After, the trimmed file passes under --replicated-database and the new file is skipped there; both pass in the default flavour. Removing the new file's pin makes it fail again with the same two lines, so the pin is load bearing rather than decorative.
Head branch was pushed to by a user without write access
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Five stateless tests diverge on the DBReplicated coverage flavours, then get force-set to
OKbythe llvm-coverage whitewash, so they catch nothing. Over 21 days the divergence (
result differs,or
having stderrorfor04318) hits 100% of the four access tests' runs and 96.4% of02440's(6449 of 6687); 26686 rows carry the whitewash (
Failed 0 out of 3 reruns).Two causes, verified locally:
04318_remote_storage_engine_access,04401_remote_storage_engine_restore_access,04401_url_engine_s3_dispatch,04489_remote_storage_engine_restore_tf_access) assert deny paths implemented insidestorage construction (
StorageDistributed.cpp,StorageURL.cpp). On a Replicated databasetryEnqueueReplicatedDDLenqueues the statement and a userless worker runs it, sofull_accessno-ops those checks and the deny path silently allows: open issue Flaky test04541_create_as_select_table_scoped_insert_grant: deniedCREATE TABLE ... AS SELECTintermittently succeeds withoutACCESS_DENIED(DatabaseReplicated) #111561.02440_mutations_finalizationpauses merge selection with the process-localSYSTEM ENABLE FAILPOINT, but the test cluster gives this shard a second replica of the sametable, whose unpaused merge-selecting task assigns the mutation that must stay pending.
A harness assumption, not a defect.
Each pin gets a
no-replicated-databasetag and a comment naming its mechanism; the access pinsalso name #111561, so
git grep 111561 tests/finds every pin when it resolves. No assertion isweakened or deleted.
04401_url_engine_s3_dispatchis pinned per subcase, not per file: only its two CREATE-timeengine-grant denials are invalidated, so a file-level tag would also have dropped five live
assertions, including the only stateless coverage of S3 source-grant dispatch. Those two subcases
move to
04401_url_engine_s3_dispatch_engine_grant, which carries the pin; the rest of the filenow runs in every flavour.
The tag reaches three configurations (replicated-database, cloud, shared-catalog), all subject to
the same gap. Over 50 randomized runs: 250/250 green on the default flavour, 250/250 skipped on
the affected one.
I am not fixing the engine here: #111561 is parked on an owner-level decision, with a write-up and
three options there. Same instrument as merged #112862.
Per-test validation (before / after, both directions)
Reproduced with
tests/clickhouse-test --replicated-database --no-stateful <test>on a 3-host,2-shard cluster matching
tests/config/config.d/database_replicated.xml.--replicated-database, before04318_remote_storage_engine_accessTABLE_ALREADY_EXISTSon the 3rd create (first two not rejected)04401_remote_storage_engine_restore_access1->0and table-absent0->104401_url_engine_s3_dispatchs3-engine-denied/azure-engine-denied->NOT DENIED,s3-source-requiredstill passed04401_url_engine_s3_dispatch_engine_grant(new)04489_remote_storage_engine_restore_tf_access02440_mutations_finalization['all_0_0_0'] 0->[] 1(pause had no effect)Mechanism corroborated in the server log: the
RESTOREarrives asuser: user_04401_..., but theCREATE TABLE ... ENGINE = Remote(...)it produces runs as(from 0.0.0.0:0, user: , ...) /* ddl_entry=query-0000000007 */and succeeds, where the testrequires it to be rejected.
04541_create_as_select_table_scoped_insert_grantand04418_create_table_as_select_subquery_accessare left failing on purpose, as the live evidencefor #111561, and are not touched here.
Why
04401_url_engine_s3_dispatchsplits: itsurl('s3://...')source-grant check is a plainSELECTanalyzed on the initiator, which has a user, and its engine-name, reload-safety andTRUNCATE-rejection checks never touch access control, so only the two CREATE-time engine denials
are invalidated. The
httpallow case moves with them because it stops a denial from passingmerely because the user holds no engine grant at all.
Version info
26.8.1.646(included in26.8and later)