Repository navigation
Fix two stateless tests a Replicated database refuses to run - #113187
PedroTadim merged 2 commits into
Conversation
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.
The previous commit scoped the closing query_log transcript to query_id = initial_query_id, so it no longer contains the rows the DDL replay worker writes on a Replicated database. That filter is correct: the replay rows are what made the byte-exact transcript diverge on that flavour. But it also removed the only coverage of the replay logging path, and the replay row is not a copy of the initiator's already-masked text. DDLTaskBase::formatRewrittenQuery sets query_str from formatWithSecretsOneLine, so it carries secrets in plaintext. DDLWorker::tryExecuteQuery then hands that string to executeQuery, which masks it again, over the DDL-rewritten AST rather than the AST the initiator masked. A regression confined to that path would leak plaintext into query_log while every remaining assertion in the file passed. Add one assertion over every row the test produces, replay rows included, that no tagged secret appears. count() > 0 is in-band anti-vacuity: an "assert no secret appears" oracle otherwise passes silently when its scoping predicate matches nothing. Both columns are flavour-independent, so one shared reference line serves Atomic and Replicated and the test still needs no tag. Measured under --replicated-database: 96 rows unfiltered against 82 filtered, a delta equal to the 14 replay rows, so the assertion does cover the path. It was proven armed two ways: injecting a statement that logs a plaintext secret flips its result from "1 0" to "1 1", and pointing its predicate at a non-existent database flips it to "0 0". 50 randomized runs pass on each flavour.
Internal second-model review (2 rounds, 3 findings adjudicated)Every change here was reviewed by a second model that did not write it, then adjudicated against the ❌ Blocking, fixed before this PR was opened
Proven to actually cover that path rather than being assumed: under 💡 Noted, not blockingThe all-row assertion is not usable under Coverage residual: Verified cleanThe refusing clause for Session id: cron:clickhouse-review-slot-9:20260803-193500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-45:20260803-173400 |
|
cc @tuanpach, could you review this? Two stateless tests fail on every run of the DBReplicated coverage flavour: one issues a mixed-kind single ALTER that InterpreterAlterQuery refuses on a Replicated database, and the other has a byte-exact query_log oracle that the DDL replay worker's second log entry breaks, so I scoped the oracle to the initiating query and added an assertion covering the replay rows rather than skipping the test. |
|
Workflow [PR], commit [c85dda3] Summary: ✅ AI ReviewSummaryThis PR fixes two deterministic Final Verdict✅ No findings. |
CI finish ledger - c85dda3Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
No check is queued or in progress, Session id: cron:our-pr-ci-monitor:20260804-033000 |
Related: #112052
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Two of the nine failures @alexey-milovidov asked me to investigate on #112052, in the
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 1/3)job. Both fail on every run of that flavour, and look flaky only because the diagnostics rerun drops
--replicated-databaseand llvm-coverage force-setsOK. Six of the nine are already fixed (#112862,#112993);
04511is a distributed-DDL timeout tracked elsewhere. Tests only.1.
03990_alter_rename_column_swap_different_types,Code: 392 QUERY_IS_PROHIBITED. One assertionissues
RENAME COLUMN ..., RENAME COLUMN ..., UPDATE ... WHERE 1as a single ALTER, whichInterpreterAlterQueryrefuses on aDatabaseReplicatedbecause it spans two command kinds. That formis the assertion: the
UPDATEforces the part rewrite exercisinggetColumnsForNewDataPartwhile therenamed-from column holds no data, so splitting it loses the #103247 coverage. Tagged
no-replicated-database, as merged for04278in #112862, which costs Replicated, Cloud andshared-catalog coverage. The file's twelve other ALTERs are single-kind and unaffected.
2.
04510_s3_explicit_url_named_secret_mask, result differs by 14 lines. Its closing oracle is abyte-exact
system.query_logtranscript scoped only bycurrent_database, and the DDL replay workerlogs each DDL a second time. Every secret is still
[HIDDEN]there: masking is intact, the oracleover-specifies. A skip tag would lose coverage of 47 tagged secrets, so I scoped the transcript with
AND query_id = initial_query_id: a replay row gets a freshquery_idbut inherits the initiator's.That path masks a rewritten AST independently instead of copying the initiator's masked text, so the
filter alone would leave a regression there undetected. So I also assert over every row, replay
included, that no tagged secret appears, guarded by
count() > 0against a vacuous pass.Both reproduce deterministically with
--replicated-database, pass after the fix, still pass withoutit, and survive 50 randomized runs per flavour. The new assertion is armed both ways.
Version info
26.8.1.814(included in26.8and later)