Repository navigation
Keep or skip five stateless tests that a Replicated database refuses to run - #112862
Conversation
…to run
On the DBReplicated coverage flavours the runner puts stateless tests on a
Replicated database, where the server refuses two statement shapes by design:
* StorageMaterializedView rejects a refreshable materialized view with no
APPEND over a non-replicated target ("This combination doesn't work ...
Refusing to create", BAD_ARGUMENTS), because the refresh would run on one
replica while the table was replaced on the others.
* InterpreterAlterQuery's validateReplicatedDatabaseSegments rejects an ALTER
mixing replicated and non-replicated actions in one statement
(QUERY_IS_PROHIBITED).
Five tests execute one of those, so they failed on every such run. The failures
were hidden rather than absent: the functional-test diagnostics rerun builds its
command without the job's own --replicated-database flag, so the failure could
not reproduce in the rerun, was labelled flaky, and was force-set OK on the
coverage jobs. That accounts for 89977 whitewashed-OK rows over 21 days.
The engine sanity-check block holding the first refusal is gated on !fixed_uuid,
and fixed_uuid is the APPEND flag, so APPEND skips the refusal outright. Two
tests therefore keep running on every flavour via an APPEND fixture instead of
losing that coverage:
* 03981_refreshable_mv_retries_int64_max: its subject is the signed-overflow
guard when refresh_retries is INT64_MAX. The retry machinery never reads the
append flag, and the guarded site was measured to still be reached, printing
"(attempt 4/9223372036854775808)".
* 04247_attach_table_storage_clauses_without_engine_error: its subject is the
ATTACH rejection surface, decided before storage construction. EMPTY is
added too, so no initial refresh appends a row into the target the ATTACH
cases read.
The other three get no-replicated-database, because for them the refused
statement is the assertion: 04617_pr_plan_based_materialized_view asserts the
APPEND/non-APPEND distinction in both arms, and both
04278_json_minmax_index_mixed_type_array and 04062_table_readonly_replicated
assert a single mixed ALTER. This records a server-enforced engine
incompatibility, not a randomization silencer: no no-random-* tag is added, and
50 randomized runs of all five tests give 250 passes. The tag also skips Cloud
and shared-catalog runs, which reach the same refusals.
04062's symptom was a result-differs rather than an error, which looked like a
behavioural divergence. It is the same mixed-ALTER refusal, masked: on a plain
database the statement returns the expected NOT_IMPLEMENTED, while a Replicated
database intercepts it in segment validation first and the shell wrapper turns
that into a 0.
No reference file changed. Reverting the APPEND or removing a tag reddens
exactly the affected tests with the refusal quoted above.
The test exists to pin the signed-overflow guard in RefreshTask::executeRefresh, which formats "(attempt N/total)" as static_cast<UInt64>(refresh_retries) + 1 so that refresh_retries = INT64_MAX prints 9223372036854775808 rather than overflowing. Its oracle could not observe that branch. system.view_refreshes.retry is the internal attempt counter minus one while a refresh is in flight, so retry == 1 has two preimages: attempt 1 has failed and attempt 2 has not started, or attempt 2 is running. Only the second implies the branch ran, and the first is entered first, separated from it by the retry backoff. The poll broke on the first retry >= 1 sighting and the final assertion re-read the same threshold, so the test could pass having executed only attempt 1. Raise both to retry >= 2, which is reachable only once attempt 2 has entered executeRefresh, and additionally assert the produced comment itself from system.query_log so a regression in the guard's arithmetic changes the asserted value rather than only the counter. The reference gains the matching row. Measured over a matrix of fixture, threshold and the new assertion: with refresh_retries = 0, so attempt 1 fails and no retry is ever scheduled, the previous form still printed "ok 1" and passed, while the new form reports ok 0 and formatted 0. Each change alone also converts that vacuous pass into a failure, so neither is redundant. On a healthy server the test passes 20 of 20 unrandomized and 50 of 50 randomized runs, and it still runs (rather than being skipped) with --replicated-database, where reverting the APPEND fixture keyword restores the Code 36 refusal.
03981_refreshable_mv_retries_int64_max asserts that the retry formatting branch in RefreshTask::executeRefresh produced '(attempt N/9223372036854775808)', by reading system.query_log for the refresh's log_comment. On a Replicated database an APPEND refreshable view is coordinated by default (all_replicas defaults to false), so the refresh runs on one arbitrarily chosen same-shard replica. The retry counter survives that, because it lives in the shared Keeper znode, but query_log does not: it is written into the process-local log of whichever server ran the refresh, while the test client is connected to one server. On the coverage DBReplicated flavour two servers share a shard, so the assertion is intermittently lost when the other replica wins the refresh lock. Setting all_replicas = 1 keeps refresh uncoordinated, so every replica refreshes locally and the connected one always produces both its own retry counter and its own query_log row. The setting exists for exactly this choice: in APPEND mode both modes are meaningful. It cannot perturb what the test measures, because the attempt counter, the retry scheduling and the formatting branch are all unconditional on coordination, and it is a no-op on a plain database. Measured on two servers sharing one Keeper with the same shard macro and different replica macros: with the setting the assertion holds in 12 of 12 runs; without it it fails in 3 of 12 while the retry assertion passes in all runs. With the setting no coordination znode is created at all; without it /clickhouse/tables/<uuid>/<shard>/replicas exists and lists both replicas. Also reword the wait comment: retry >= 2 establishes that attempt 2 entered executeRefresh, which is weaker than the previous heading claimed. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model review (click to expand)Before opening this PR I ran an internal review pass: an independent cold code Rounds: 3 review rounds, 2 fix rounds. 14 findings adjudicated: 1 blocker
Claims in the diff's own comments were treated as claims and each checked |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-9:20260801-050002 |
|
cc @tuanpach, could you review this? Five stateless tests execute a statement a Replicated database refuses, so they fail deterministically on the DBReplicated coverage flavours; two keep running there via an APPEND fixture, because the engine sanity-check block holding the refusal is skipped when APPEND is set, and the three whose refused statement is the assertion get no-replicated-database. |
|
Workflow [PR], commit [8107172] Summary: ✅ AI ReviewSummaryThis PR fixes five stateless tests that deterministically fail on Final Verdict✅ No new findings. |
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 #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. #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 #112862.
Both fail on every run of the Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 1/3) job. They read as flaky only because the llvm-coverage diagnostics rerun drops --replicated-database, so the failure reruns green, is labelled flaky, and is force-set to OK in the CI database. Requested by alexey-milovidov on ClickHouse#112052. 03990_alter_rename_column_swap_different_types One assertion issues RENAME COLUMN ..., RENAME COLUMN ..., UPDATE ... WHERE 1 as a single ALTER. InterpreterAlterQuery groups an ALTER's commands into segments by kind, and validateReplicatedDatabaseSegments rejects any multi-segment ALTER on a DatabaseReplicated, so the server refuses the statement with Code: 392 QUERY_IS_PROHIBITED before any storage code runs. The combined form is the assertion: the non-key UPDATE is what forces the part to be rewritten by the mutation, so getColumnsForNewDataPart processes the part while the renamed-from column holds no data. Splitting it into two ALTERs would make the mutation observe a different part state and stop exercising the issue ClickHouse#103247 code path, so the honest fix is the tag. This matches the disposition already merged for the sibling test 04278 in ClickHouse#112862. The other twelve ALTERs in the file are single-kind and execute normally on a Replicated database, verified individually. The tag also suppresses Cloud and shared-catalog runs, which is a real coverage cost, accepted because the statement is unsupported there. 04510_s3_explicit_url_named_secret_mask The closing oracle compares a byte-exact system.query_log transcript scoped only by current_database. On a Replicated database the DDL replay worker logs each DDL a second time, so the transcript gains 7 replayed entries and 7 rewritten CREATE statements with a materialized UUID: 14 extra lines. Every secret is still [HIDDEN] in those extra rows, so masking is intact and this is not a security failure; the oracle simply over-specifies which rows exist. A skip tag would delete real coverage of 47 tagged secrets across roughly 60 carriers, so the oracle is scoped to the initiating query instead. DDLTaskBase::makeQueryContext calls setCurrentQueryId(""), giving the replay context a fresh random query_id, and DDLWorker then calls setInitialQueryId(task.entry.initial_query_id), inheriting the initiator's id. For a directly issued query Context::setCurrentQueryId sets initial_query_id equal to current_query_id. So query_id = initial_query_id selects exactly the statements the test issued, on both Atomic and Replicated databases, and the reference needs no change. Filtering on the text of the ddl_entry comment was rejected as a fragile match on the very column under assertion; is_replicated_database_internal is semantically exact but is not exposed in query_log. Validation: both reproduce deterministically with --replicated-database and pass after the fix, both still pass without it, and each survives 50 randomized runs per flavour. The 04510 filter was checked for vacuity in both directions: injecting a statement that logs a plaintext secret as an initiating row still makes the filtered oracle fail, and on a non-Replicated database the added clause changes nothing.
Related: #112247
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
On the
DBReplicatedcoverage flavours the runner puts stateless tests on a Replicateddatabase, and five of them execute a statement the server refuses there by design. Those
failures were hidden: the diagnostics rerun drops the job's
--replicated-databaseflag, sothey were labelled
flakyand force-setOK(over 94,000 such rows in the last 21 days). #112247fixes the visibility; this makes the five stop failing.
Two refusals are involved, both unconditional throws with no relaxing setting:
StorageMaterializedView.cpprejects a refreshable materialized view with noAPPENDover anon-replicated target on a Replicated database, and
InterpreterAlterQueryrejects anALTERmixing replicated and non-replicated actions in one statement.
The engine sanity-check block holding the first refusal is skipped when
APPENDis set, so twotests keep running on every flavour via an
APPENDfixture instead of losing that coverage:03981_refreshable_mv_retries_int64_maxand04247_attach_table_storage_clauses_without_engine_error.04247's assertions are unchanged.03981also raises its retry threshold, so the wait can no longer be satisfied before the secondattempt starts, and asserts the comment that attempt formats; its reference gains one row.
The remaining three get
no-replicated-database, because for them the refused statement isthe assertion:
04617_pr_plan_based_materialized_viewasserts theAPPEND/non-APPENDdistinction in both arms, and
04278_json_minmax_index_mixed_type_arrayplus04062_table_readonly_replicatedeach assert a single mixedALTER. This records aserver-enforced engine incompatibility, not a randomization silencer: no
no-random-*tag isadded and randomization stays green on its own. Note the tag also skips Cloud and
shared-catalog runs, where the same refusals apply.
Validation: each rewrite verified to keep its assertion on a plain server and to newly pass with
--replicated-database; each tag verified to skip rather than fail. Reverting theAPPENDorremoving a tag reddens exactly the affected tests with the refusal above. 50 randomized runs of
all five: 250 OK, 0 failures.
Version info
26.8.1.596(included in26.8and later)