Repository navigation
Add coverage tests for three untested MergeTree/replication branches - #114296
PedroTadim merged 3 commits into
Conversation
Re-files three closed clickgapai coverage PRs (ClickHouse#101781, ClickHouse#103935, ClickHouse#103939) that @ zlareb1 asked to be reopened. A fourth, ClickHouse#101284, is not included: its mechanism is already pinned by five existing tests, so it would be a duplicate. Each branch was mutated, rebuilt and re-run to confirm the test detects it, and each mutation had to leave the pre-existing tests of the same mechanism green so that reddening is evidence of incremental coverage rather than of the mechanism merely being live. Two of the three originals failed that check: - ClickHouse#101781 asserted count() = 3 after the writer merged. The pre-merge state is also 3 rows, so a run in which the refresh never happened is indistinguishable from a correct one. An active-part count is no better: refreshDataPartsOnce commits the merged part with the same Transaction::commit that demotes the parts it covers, upstream of grabOldParts, so the active set is 1 in both directions. The test now asserts the part state through the _state virtual column, which is Deleting on master and Outdated when grabOldParts is not asked to force removal. The refresh is driven by SYSTEM RESTART DISK, which calls the same body synchronously, so no sleep is needed, and the writer's merges are bracketed by SYSTEM STOP/START MERGES so its own scheduler cannot merge the three inserts before the first assertion. - ClickHouse#103939 asserted count() <= 10 while a REPLACE PARTITION and a mutation raced for ten seconds. That passes whenever the race is not won, which is the likely outcome; measured against a binary with the guard broken, it still passes. It is replaced by a deterministic sequence: the REPLACE is parked inside its own intent window on the existing rmt_cancel_removed_parts_check_pause_in_gap failpoint, reached from replacePartitionFrom via cancelRemovedPartsCheck while the intent is held, and the test then asserts the mutation entry's postpone_reason in system.replication_queue. That column is the one the guard writes; system.mutations.parts_postpone_reasons carries a different vocabulary fed only by the merge-selection path, so polling it would never observe this. ClickHouse#103935 was sound and is adopted close to as written. Only its cited line was stale: the override is at AggregatingTransform.cpp:150, not :143. The coverage gaps were measured against the mechanism rather than the setting name, which is what the ClickHouse#101284 duplicate turned on. None of the four refresh_parts_interval tests ever merges, no test asserts read_rows after an external GROUP BY spills through any observable, and no test contains the intent guard's message. no-parallel is on the replication test only, and is earned rather than assumed: run concurrently with itself the untagged form fails because a second copy consumes the once-only pause, while the tagged form passes. The other two carry no such tag and were run concurrently with themselves to confirm it.
Review round 1: each of the three tests could pass while the branch it names is broken, which is the same vacuity the tests were written to remove from the closed PRs they replace. No production code is touched. The read_rows test ran its query twice: once to prove the aggregation spilled, once over HTTP to read the summary, so the assertion was made about a run whose spill was never verified. That is reachable rather than theoretical, because the query produces exactly group_by_two_level_threshold distinct keys and the spill needs the threshold to be crossed, so whether it spills is decided per run; a non-spilling second run legitimately reports 100000 and prints read_rows_correct with the getReadProgress override deleted. It now runs once under a query id scoped to the test database and reads both facts from that row of query_log, which is the same progress accounting the summary reported. A query id, unlike a log comment, cannot be inherited by a fuzzed re-execution, so no fuzzer pin is needed. The row is taken with LIMIT 1 rather than an aggregate, so that no row at all leaves both values empty and fails loudly. The intent guard is consulted before the first entry-type branch in shouldExecuteLogEntry, so any entry producing a part in the replaced range writes the same postpone reason, and the test matched on database and table only. It now names MUTATE_PART, which is the type its own captured reason carries. Measured against a binary with the intent match neutered, no intent reason is written for any entry type, so the arm still fails for the original reason rather than for the added filter. The mutation-settle loop had no failure branch, so after 120 polls it fell through to a row assertion that the REPLACE PARTITION alone satisfies, leaving a stuck mutation green. It now reports a timeout, silently on success so the reference is unchanged. Forcing that path makes the test fail with the token, which two earlier attempts at the control did not: stopping the replication queue and parking the mutate task both left the test green, because the REPLACE drops the part the mutation targeted and the mutation is already done by the time the loop is reached. Both mutation arms were rebuilt with the Build ID asserted to move, and each left the pre-existing tests of the same mechanism green. The three references are byte-identical, every tag and setting survives, and both edited tests ran 50 randomized plus 50 fixed-settings runs without a failure.
Internal second-model review (click to expand)Two review rounds before publishing: an independent cold read of the resulting code, then a Round 1: 3 accepted, all test-liveness
Round 2: 1 nit, not blocking
Also verified independently of the implementation notes, so these are not taken on trust: Two further nits were raised and dropped with evidence: the ZooKeeper path uses the Session id: cron:clickhouse-review-slot-9:20260811-080600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20260811-043300 |
|
cc @tiandiwonder, could you review this? It is test-only: three coverage tests for branches nothing pinned, and each replaces its source PR's oracle, which I measured to pass with the mechanism broken (a part-state assertion via |
|
Workflow [PR], commit [d19fa93] Summary: ❌
AI ReviewSummaryThis PR adds three stateless coverage tests for readonly Final Verdict✅ No new findings in the current diff. No inline review comments posted. |
The style check's *.sh branch (ci/jobs/scripts/check_style/various_checks.sh)
accepts only the literals $CLICKHOUSE_TEST_ZOOKEEPER_PREFIX or {database} inside
a ReplicatedMergeTree argument list. The .sql branch additionally accepts
currentDatabase() and {uuid}, which is why the ${CLICKHOUSE_DATABASE} form read
as correct.
Uniqueness is not weakened: shell_config.sh exports
CLICKHOUSE_TEST_ZOOKEEPER_PREFIX as "${CLICKHOUSE_TEST_NAME}_${CLICKHOUSE_DATABASE}",
so the new path still carries the database and adds the test name. Verified in
system.replicas and system.zookeeper that the tables occupy the new path, and
re-ran the oracle plus its settle-guard negative control against it.
|
Style check fixed in d19fa93. The The path change moves which znodes the tables occupy, so it was re-validated rather than assumed No coverage ran on Session id: cron:clickhouse-maint-slot-14:20260811-110100 |
CI finish ledger - d19fa93Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task Run shape, so nobody reads this as a thin run: 175 checks = 2 failure / 56 success / 117 skipped,
Neither failure touches this PR's diff, which adds three stateless test files and changes no
Session id: cron:our-pr-ci-monitor:20260811-160000 |
a96787f
Related: #101781
Related: #103935
Related: #103939
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Test-only, 6 files, no
src/changes. @ zlareb1 asked me to re-file a batch of closedclickgapaicoverage PRs; this is the MergeTree-refresh / progress / replication group. A fourth (#101284,skip_unused_shardsthrough nested views) is not included: its mechanism is already pinned by five existing tests, and I have said so on its own thread instead of shipping a duplicate.For each original I mutated the exact line it claims to cover, rebuilt, and required that test to fail while the others and the pre-existing tests of the same mechanism stayed green. All three oracles passed with their mechanism broken:
count() = 3passes when the refresh never runs, because the pre-merge state is also 3 rows. An active-part count is no better:Transaction::commitdemotes the covered parts itself, upstream ofgrabOldParts, so the active set is 1 in both arms of the mutation. The test now asserts the part state via_state:Deletingon master,Outdatedunder the mutation.ALTER ... UPDATE+REPLACE PARTITIONonReplicatedMergeTreeexercising the new initiator-side intent + cancelInPartition guards #103939'scount() <= 10passes whenever its race is not won, the likely outcome, and it passes under the mutation too. Replaced by a deterministic sequence: theREPLACE PARTITIONis parked inside its own intent window on an existingPAUSEABLE_ONCEfailpoint, and the mutation entry'ssystem.replication_queue.postpone_reasonis asserted. No sleeps, no race.read_rowsafter external GROUP BY is not asserted anywhere —SourceFromNativeStream::getReadProgressoverride untested #103935 assertedread_rowsabout an unverified run: it ran the query twice, once to prove the spill and once over HTTP for the summary. The query yields exactlygroup_by_two_level_thresholdkeys, so spilling is decided per run, and a non-spilling second run reports100000and passes with the override deleted. It now runs once under a query id and reads both facts from thatsystem.query_logrow, the same accounting the summary reported. Its cited line was stale too (AggregatingTransform.cpp:143->:150).Validation
Debug build,
clickhouse-testwith randomization on (the CI default). Each mutation changes the branch's output rather than deleting it, so a fall-through to an equivalent path cannot be mistaken for a vacuous test. Every arm was reverted and rebuilt before the next, with the Build ID asserted to change and to match the running server's.04089_merge_tree_refresh_after_mergeMergeTreeData.cpp:3289grabOldParts(true)->(false)Deleting 3->Outdated 3); other 2 OK04201_read_rows_external_group_byAggregatingTransform.cpp:150getReadProgressoverride deletedread_rows_wrong:200000, exactly 2x the input); other 2 OK04201_replicated_replace_partition_drop_intentReplicatedMergeTreeQueue.cpp:284intent match neuteredintent: yes->no); other 2 OKEach mutation also had to leave the pre-existing tests of the same mechanism green, so that "it reddens when I break the code" is not mistaken for incremental coverage: the four
refresh_parts_intervaltests, the two spill tests, and sevenREPLACE PARTITION/ part-check tests respectively. All green.--no-random-settingsruns of each: 0 failures, so nothing needed pinning beyond the tags the sibling tests already carry.no-parallel.no-parallelon the third is earned rather than assumed: concurrently with itself the untagged form gives 2 OK / 2 FAIL, and with the once-only pause released mid-window it fails outright, while the tagged form is 4/4 OK.refresh_parts_intervaltests everOPTIMIZE; none assertsread_rowsafter a spill; none contains the intent guard's message.Version info
26.8.1.1210(included in26.8and later)