Repository navigation
Pin part_loading_tree_rollback tests to the local default storage policy - #111922
alexey-milovidov merged 2 commits into
Conversation
The five part_loading_tree_rollback tests (04063/04241/04417/04500/04624) fabricate MergeTree parts out-of-band with a raw plaintext txn_version.txt and remove them via a path derived from the `default` disk. Both steps only work when the table lives on the local default disk, but harnesses that set an object-storage default MergeTree policy without passing --s3-storage to clickhouse-test (the Stress check, and the Upgrade check before ClickHouse#111772) run these tests anyway: the raw fixture file does not parse as object-storage metadata (Code 27 -> CORRUPTED_DATA on attach), and the uuid-based recovery rm -rf misses the real data path. Pinning storage_policy = 'default' makes the fixture and the recovery path correct on any server default policy and restores the tests' intended coverage on object-storage-default Stress runs. Related: ClickHouse#111053
Internal second-model review - adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding), plus my own cold
Severity: ❌ blocker / Independently verified and found clean: the pin resolves to a local disk on every harness Session id: cron:clickhouse-review-slot-8:20260725-220200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-8:20260725-220200 |
|
cc @tiandiwonder - could you review this? Test-only: the five |
|
Workflow [PR], commit [305085b] Summary: ✅ AI ReviewSummaryThis PR pins the five Final Verdict
|
CI finish ledger — a326008Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Not PR-caused: this PR only pins Session id: cron:our-pr-ci-monitor:20260726-063000 |
|
Fixing PR for the |
CI finish ledger - a326008Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Fast test, Style check and Bugfix validation are green on this head; this PR only pins the storage policy of the 04417 part_loading_tree_rollback tests, so the 04625 result-diff is unrelated. Session id: cron:our-pr-ci-monitor:20260726-163000 |
|
Functional tests shall not fabricate or manually intervene with the data parts, outside of what is reachable from the ClickHouse API surface. Find all tests that violate this rule and transform them to an integration test. |
|
I enumerated the stateless suite for this rule: 25 tests write into a server-owned part directory at a path derived from Fabricate part directories or raw part metadata (18):
Corrupt or delete parts the server itself wrote (7): Same rule, not a part directory: Checked and excluded as read-only or API-surface: Plan: convert into one integration module per mechanism instead of 25 modules, reusing On this PR: it only pins |
|
@groeneai, go ahead with this plan. |
CI finish ledger - 305085bCI fully finished on this head:
This head is a plain master merge on top of the previously ledgered Session id: cron:our-pr-ci-monitor:20260728-053000 |
Master modified all five stateless part_loading_tree_rollback tests that this branch deletes, so every conflict is a modify/delete pair. Resolved delete-wins: the conversion supersedes the master-side change. The master-side commit is a326008 "Pin part_loading_tree_rollback tests to the local default storage policy" (ClickHouse#111922), the stopgap that pinned storage_policy = 'default' so a raw plaintext txn_version.txt would still parse on jobs whose default policy is object storage. That knowledge is already carried by the integration module: create_table_with_one_part pins the same setting and documents why. Nothing from the master side is lost by dropping these files. Coverage was verified before resolving. Four of the deleted tests map one to one onto test_reparent, test_contains, test_evict_reinsert_contains and test_tmp_metadata. The fifth, 04624_part_loading_tree_rollback_startup_recovery, has no counterpart and needs none: its own header states it regression-tests the bash cleanup helper shared by the other four, recovering from a table leaked in the DETACH TABLE ... PERMANENTLY state by a run killed before its EXIT trap. The integration module uses DETACH TABLE ... SYNC, has no shared shell helper, and creates and tears down its cluster per module, so that leak cannot survive into a later run. It also derives the part directory from system.parts.path instead of reconstructing it from the default disk and the table uuid, which is the very fragility 04624 existed to guard. No ClickHouse behaviour is covered by 04624 alone.
Functional tests must not fabricate or manually intervene with data parts outside what the ClickHouse API surface exposes. A stateless test that writes a plaintext file into a part directory silently assumes the part lives on a local default disk: on an object-storage disk every file inside a part directory must be in DiskObjectStorageMetadata format, so a raw plaintext txn_version.txt cannot deserialize, part loading fails with CORRUPTED_DATA and the server does not start. The cleanup path derived its target from the default disk, so on an object-storage policy it also missed the real data path and leaked the poisoned part, breaking every later start. That assumption cannot be expressed in a stateless test because the harness owns and randomizes the disk configuration, and the no-object-storage skip tags were inert because the harness did not forward the matching flag. An integration test owns its own server and disk configuration, so the assumption becomes explicit and enforced by construction. The four PartLoadingTree::add rollback scenarios move into one module with their fabricated part lattices and transaction-metadata payloads preserved byte for byte, and their assertions strengthened from per-part active counts to whole-active-set equality. Each scenario's liveness was verified by mutation: breaking its fabrication produces exactly the failure that scenario exists to catch, and the outcomes differ per scenario - the containment arm never consults the transaction status, so its mutation lets ATTACH succeed and only the active-set assertion catches the regression. 04624_part_loading_tree_rollback_startup_recovery is deleted without a replacement. Its subject was the stateless-only DETACH TABLE ... PERMANENTLY cleanup helper, machinery that only existed to survive a stress-test server restart landing mid-script; an integration test owns its server, so the subject ceases to exist. Nothing in it reached PartLoadingTree::add. This removes the Stress-suite failures, which run the master tree's test files. It does not affect the Upgrade check, which clones the previous release tag and runs its frozen test files. Related: ClickHouse#111053 Related: ClickHouse#111922
StorageLog::saveFileSizes recorded the size of each stream separately, and each FileChecker::update does IO that can throw. A throw partway through left new sizes recorded for streams 0..k-1 and old ones for k..n. Because the insert had not finished, ~LogSink calls FileChecker::repair(), which truncates every file to its recorded size, so adjacent streams of one array column were left at different generations: the outer offsets then described more elements than the inner streams held, and a sort over such a column indexed the elements out of bounds. A throw inside save() has the opposite effect. Its four throw points sit after the map has been updated, and the data files were appended in place, so repair() truncates nothing and an insert that reported failure keeps its rows. FileChecker::updateAndSave() now collects the sizes into a candidate map, persists that, and adopts it only once the persist has succeeded, so the recorded sizes and the files can no longer disagree. StorageStripeLog had the same defect and is fixed the same way. The marks file is itself one of the files whose size is recorded, so a rollback to the old sizes truncates it. saveMarks() had already advanced num_marks_saved by that point, which left removeUnsavedMarks() discarding nothing and the in-memory marks describing a file that no longer contained them. The counter is restored when the size commit fails, in both storages and on both the insert and the backup restore paths. LogSource::readData() already validated the type of the column it deserialized. It now also validates, at every nesting level, that an array's last offset matches the number of elements it holds, and raises INCORRECT_DATA naming the column instead of passing a column that lies about its own length to the query pipeline. The write defect was found while investigating a ColumnArray::indexImpl assertion failure in BuzzHouse (amd_tsan), STID 2508-2944. How the table in that run reached the inconsistent state is not established: its log records no truncation by repair(), so this commit path is not shown to be what produced it, which is why the read side is validated as well. Tests: 04931_log_family_failed_insert_commit covers the write half over Log, TinyLog and StripeLog and both failure windows, using failpoints conditioned so they fire on the commit at the end of the insert rather than on the empty baseline commit the sink makes at construction. test_storage_log_damaged_array covers the read half; it edits data files directly, so per ClickHouse#111922 it cannot be a functional test.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #111053
The five
part_loading_tree_rollbacktests (04063/04241/04417/04500/04624) fabricate MergeTree parts out of band: theycp -ra committed part directory and write a raw plaintexttxn_version.txtinto it, then attach or restart-recover and assertPartLoadingTreerollback behavior. This has two hard dependencies on the table living on the localdefaultdisk:DiskObjectStorageMetadataformat, so the raw plaintexttxn_version.txtfails to parse (Code 27). The loader then treats the transaction status as unreadable and, for the fabricated intersecting part pairs, throwsCORRUPTED_DATA:cleanup/recover_leaked_tablecomputes the fabricated-part path from thedefaultdisk (SELECT path FROM system.disks WHERE name = 'default'), which is only correct if the table's data actually lives there.The tests do not pin the storage policy, so any harness that sets an object-storage default MergeTree policy without passing
--s3-storage/--azure-blob-storagetoclickhouse-test(those flags are what arm theno-object-storagetag) runs them in a broken configuration. The Stress check is exactly such a harness:stress_runner.shnever forwards--s3-storage/--azure-blob-storagetoclickhouse-test, while its policy randomization makes an object-storage default in roughly two thirds of runs. On those runs the tag is inert and the fixture attach fails, so 04063/04241/04417/04500 reportFAIL: ATTACH TABLE threw an exceptionfor a configuration problem rather than for the rollback regression they exist to catch, and 04624 fails differently and silently: its uuid-based recoveryrm -rfis computed from thedefaultdisk and misses the real object-storage data path.Fix: pin all five tests to
SETTINGS storage_policy = 'default'(04624 on both of itsCREATE TABLEstatements). A policy nameddefaultis never redefined by the test configs, andStoragePolicySelectorsynthesizes it over the localdefaultdisk when it is not explicitly configured, so this makes both dependencies correct by construction on any server default policy and restores the tests' intended coverage on object-storage-default Stress runs. The part-loaderCORRUPTED_DATAguard is left untouched: it must keep failing loud on genuine corruption. No assertions change.The same signature also fires in the Upgrade check, for example https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108091&sha=8397a5cad3ccb556cbda7e2a4f56cdf789169737&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 (
Upgrade check (amd_release)). That check does pass--s3-storage, but it runs the previous release copies of the test files, which no change to master's tests can reach. It is addressed separately by #111772, which forwards the storage flags in the runner so the skip tags fire there. This PR is complementary: it removes the tests' dependency on the server default policy at the source, which acts immediately in the Stress check where those flags are not forwarded. There is no file overlap and no ordering constraint between the two.The pin mechanism was originally in #110999, which was closed as superseded by #111055; #111055 fixed the separate stress-restart poisoning but not the object-storage mismatch, which is what this PR addresses (now also extended to 04624).
Verified locally: on an object-storage-default server the unpinned
CREATEreproduces the failure (attach -> Code 246, plus the startup errors quoted above after a restart), and the pinnedCREATEon the same server attaches cleanly with correct part active states and zero startup errors. The family passes 50x (04417) and 15x each (siblings), and all five pass against their.reference.Version info
26.8.1.281(included in26.8and later)