Repository navigation
Add test: No test for merge handling in readonly MergeTree refresh (refreshDataParts covers parts by Transaction::commit) - #101781
clickgapai wants to merge 1 commit into
Conversation
|
@groeneai can you take this up and open a new PR? |
|
Taking these up. I triaged all 26 of this batch against master All 26 are viable. Every diff is test-only and applies cleanly, and every cited source line still exists on master, so none of them is obsolete by code removal. I am not declining any of this batch. One test needs a fix before it can be re-filed. #103889 asserts I mutation-tested the oracles rather than trusting a green run. Two examples, both proven to really assert something: #103920's default expression I am keeping the existing test numbers. I had carried forward a note that these all needed renumbering, and that turns out to be wrong: master has 13192 stateless tests across only 3755 distinct numeric prefixes, so shared prefixes are normal, and the only filename rule in CI ( Two caveats on scope. #101284 needs a real server (it is On packaging: this is the second batch today, 26 here plus 18 from the earlier one, 44 tests total. I am not going to open 44 PRs. I will group them by area (formats/IO, MergeTree/replication, analyzer/planner, functions/types, dictionaries, access) and post the resulting PR links here. If any individual test turns out not to hold up once it is under real CI, I will say so on its own PR with the reason instead of quietly dropping it. |
|
First of the grouped PRs from this batch: #114260, the functions/types group, covering six of the gaps (#103918, #103922, #103940, #107447, #103885, #103931). #103897 is declined, with the reason posted on its own PR: the Each adopted test was mutation-checked rather than taken on trust: I changed the exact line it claims to cover, rebuilt, and required that test to fail while the others stayed green. That found three defects in the originals, including one test that was flaky by construction because its arguments were read in the session timezone, which CI randomizes. The remaining 19 gaps from this batch are being grouped the same way (formats/IO, MergeTree/replication, analyzer/planner, dictionaries, access); links will follow here. |
|
Group B of the re-file, covering the dictionaries and columns PRs: #114287
Every assertion was mutation-tested rather than merely run: corrupt the line it claims to pin, confirm the test reddens, revert, confirm it passes. That found five defects in the adopted #103913, which are described in the PR. |
|
Group D of this batch, the analyzer/views group: #114293, covering three of the five gaps (#103925, #103930, #103914). Two are declined, each with the reason posted on its own PR rather than left silent. #103923's alias-qualified One of the three shrank on inspection: #103930 ships as a single added assertion inside the existing As with group A, each adopted test was mutation-checked rather than taken on trust: I changed the exact line it claims to cover, rebuilt, and required that test to fail while the others stayed green. That also corrected two of my own earlier claims, one about a view carrying no definer to clear, and one about which existing tests reach the Group A was #114260. The remaining groups from this batch are in flight and links will follow here. |
|
Re-filed as #114296, the MergeTree-refresh / progress / replication group, covering this gap together with #103935 and #103939. The test here is not the original one. Its Found the same way as in the earlier groups: I mutated the exact line the test claims to cover ( #101284 from this group is declined, with the reason posted on its own PR. |
|
Group C of this batch, the MergeTree/index group: #114305, covering four of the seven gaps (#101750, #103984, #108884, #108815). #108815 is folded into my existing Three are declined, each with the reason on its own PR: #101724 (the oracle is satisfied by a type error raised upstream of the guard it claims to cover, so it passes with that guard deleted), #103889 (the disk combination is already exercised by Two of the four adopted tests turned out to pass without ever reaching their guard. |
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.
Re-files three of five closed clickgapai coverage PRs (103925, 103930, 103914) that zlareb1 asked to be re-filed via ClickHouse#101781. Two of the five are declined with the reason posted on their own threads: 101743 (its reference would freeze an unresolved CREATE-time-vs-runtime MV validation semantic, an owner-level call) and 103923 (its only site beyond 04338 is the cache-hit copy, which leaves the cached query tree unrewritten, so it is not observable from SQL). Each shipped test was falsified rather than taken on trust: the exact line it claims to cover was mutated, the binary rebuilt with the Build ID asserted to move, and the test required to fail while neighbouring tests stayed green. - 04201_attach_table_missing_database pins the UNKNOWN_DATABASE throw in the stub-ATTACH block of InterpreterCreateQuery.cpp. No file under tests/ asserts UNKNOWN_DATABASE for an ATTACH, and the qualified bare-ATTACH tests on master all attach into a database that exists first. The sibling throw on the createTable path is uncovered too and stays out of scope here. Because the mutation is injected at that throw, only a statement resolving there can redden, which is what pins the site. One statement: ATTACH DICTIONARY reaches the identical throw before any is_dictionary discrimination. - 04201_force_null_for_omitted_jsoncolumns pins the force-null check in JSONColumnsBlockInputFormatBase. That setting has six independent copies in src/ and 03004 covers five, not this one. Two rows rather than eight: JSONColumns, JSONCompactColumns and JSONColumnsWithMetadata were measured to emit a byte-identical exception from the same base class, so they are one dispatch. Negating the type predicate reddens this test while 03004 stays green, so the sibling copies are untouched. - 02884_create_view_with_sql_security_option gains one assertion instead of a new file. It already performs the definer-to-invoker transition and reads SHOW CREATE TABLE; only the negative check that the definer is gone was missing. The pattern needs the equals sign, since a bare DEFINER also matches SQL SECURITY DEFINER. Leaving the definer uncleared flips that assertion from 0 to 1 and changes nothing else in the file, while its existing SQL SECURITY INVOKER row stays 1 and so serves as the did-the-ALTER-run control. The ATTACH reference is empty, which is correct for a serverError-only test, and was verified on stderr: a stray newline or a wrong error code both fail. The 02884 reference line was placed by running the test and rebuilding the file from its output, not by hand. The ATTACH test is scoped to CLICKHOUSE_DATABASE_1 rather than a server-global database name so it is safe to run against itself. Both new tests passed 50 runs with randomized settings and 50 with --no-random-settings, plus four concurrent copies of themselves and a joint run with 03004, 04126, 04010, 04141 and 02884, so neither needs no-parallel.
Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.
Retrospective finding from a historical scan of PR #79033 (merged 2025-04-11). Confirmed on current codebase — close with a note if already fixed.
Adds test coverage for 1 untested code path(s), found during automated review of PR #79033.
1. No test for merge handling in readonly MergeTree refresh (refreshDataParts covers parts by Transaction::commit)
src/Storages/MergeTree/MergeTreeData.cpp:2660,src/Storages/MergeTree/MergeTreeData.cpp:2688Why this test: MergeTreeData::refreshDataParts (MergeTreeData.cpp:2620) loads new parts and adds them via Transaction::commit which calls getActivePartsToReplace to mark old covered parts as Outdated. This merge han
What's unique: PR's test 03362 covers only basic single INSERT + read. This test covers the merge handling path: multiple inserts → writer merge → reader refresh correctly handling covered parts without duplicates.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not applicable — test-only change.
Documentation entry for user-facing changes
Found during review of PR #79033.