Repository navigation
Detach tables permanently in part-loading-tree rollback tests - #111055
Conversation
The `04241_part_loading_tree_rollback_contains` and `04063_part_loading_tree_rollback_reparent` tests fabricate part directories out-of-band while the table is `DETACH`-ed. A plain `DETACH` does not survive a server restart, and stress tests restart the server at arbitrary moments — the table is then loaded again at startup while the script is still writing `txn_version.txt(.tmp)` files, and the server's version-metadata machinery races with the script on those files, leaving corrupted metadata behind. Every subsequent server start then fails with `Cannot parse input` while loading the table, which fails the whole stress run with "Cannot start clickhouse-server". Use `DETACH TABLE ... PERMANENTLY` so the table stays detached across restarts; the explicit `ATTACH TABLE` still re-attaches it. Closes: #111053 Example report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110246&sha=72768ce112527547fd077031893e6c2c7404b30f&name_0=PR&name_1=Stress%20test%20%28arm_msan%29 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [bf7895c] Summary: ✅ AI ReviewSummaryThis PR updates the four Final VerdictStatus: ✅ Approve |
… tests The `04417_part_loading_tree_rollback_evict_reinsert_contains` and `04500_part_loading_tree_rollback_tmp_metadata` tests fabricate part directories out-of-band while the table is `DETACH`-ed, exactly like their siblings already fixed in this PR, and hit the same corruption under stress-test restarts: a stress run of #109004 failed with `Part all_5_6_1_0 intersects previous part all_1_5_4_1 and the transaction metadata of at least one of them could not be read` while loading `t_plt_evict_reinsert` at startup, failing the run with "Cannot start clickhouse-server". Use `DETACH TABLE ... PERMANENTLY` in these two tests as well. Example report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109004&sha=e26111dca401681dbc6b4ba4a9c42b6fe23a4a36&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 Related: #109004 Co-Authored-By: Claude Fable 5 <[email protected]>
…ondition The `DETACH TABLE ... PERMANENTLY` client call alone is not a sufficient gate: `clickhouse-test` runs `.sh` tests under plain `bash`, so if the call fails (e.g. a stress-test server restart lands on it), the script would keep running and mutate a table directory that may still be attached, re-opening the `txn_version.txt` corruption race. Verify that the table is absent from `system.tables` and present in `system.detached_tables` with `is_permanently = 1`, and fail fast before touching anything under the table's data path. #111055
|
The single stateless failure |
A permanently detached table is invisible to `DROP TABLE` (`DROP TABLE IF EXISTS` silently does nothing) while its name still blocks `CREATE TABLE`, so on failure paths that exit before `ATTACH TABLE` succeeds the old `cleanup` leaked the table for the rest of the run. Now, if the table is still detached, `cleanup` first removes the fabricated part directories (whose transaction metadata is exactly what could have made `ATTACH` throw), re-attaches the table, and then drops it, in all four tests of the family. Verified against a live server: with an `ATTACH` failure injected in-test, the new `cleanup` leaves no trace in `system.tables` or `system.detached_tables`. Co-Authored-By: Claude Fable 5 <[email protected]>
Pulls in #111055 (fix for the unrelated stress-test startup failure #111053, 'Part all_5_6_1_0 intersects previous part' in 04241_part_loading_tree_rollback) so the Stress test (amd_tsan) red can clear on the next CI run. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109453&sha=948d74cabe4714a6f98d0d0f0e7e1a6e8518ad19&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
…_tree_rollback_startup_recovery` Two review comments on ClickHouse#111055 arrived shortly before the merge and were not addressed there: - The plain `DROP TABLE IF EXISTS` at startup silently does nothing on a table leaked in the permanently detached state by a previous run that was killed before its `EXIT` trap ran, while the leftover name still blocks `CREATE TABLE`. Call `recover_leaked_table` at startup instead, mirroring the rollback tests' `cleanup`. - The test fabricated a corrupt `txn_version.txt` right after `DETACH TABLE ... PERMANENTLY` without verifying the detach postcondition. Under stress a restart can land on the detach and, under plain `bash`, the script would fall through and write into a still-attached table's directory. Add the same fail-fast gate on `system.tables` / `system.detached_tables` with `is_permanently = 1` that the four rollback tests use. Co-Authored-By: Claude Fable 5 <[email protected]>
…-encrypted-storage The Upgrade check configures the server with object storage as the default MergeTree policy (configure --s3-storage) and randomly enables encrypted storage, but ran clickhouse-test without --s3-storage and never forwarded --encrypted-storage. So clickhouse-test had args.s3_storage / args.encrypted_storage = False and ignored its storage skip tags (no-object-storage, no-s3-storage, no-encrypted-storage): those branches in should_skip_test fire only when the matching argument is set. Tests declared incompatible with the configured backend then ran on an unsupported one. This produced the Upgrade check (amd_release) Code 27 / Code 246 failures on the four 04063/04241/04417/04500_part_loading_tree_rollback_* tests (all tagged no-object-storage): they fabricate a raw plaintext txn_version.txt in a part directory (valid only on a local disk), which is unreadable on an object-storage disk, so PartLoadingTree::add (from ClickHouse#100992) reports CORRUPTED_DATA at the test's own ATTACH. With --upgrade-check (which implies --fake-drop) the corrupt part survives into the new server, which logs the parse error at part load. ClickHouse#111055 / ClickHouse#111661 hardened these tests on master, but the Upgrade check runs the frozen previous-release test suite, so those changes cannot reach it. Forward --s3-storage (in the clickhouse-test command) and --encrypted-storage (mirroring the coin flip, via stress.py) so clickhouse-test matches the server's actual configuration and skips incompatible tests, as the regular stress runner already does. Related: ClickHouse#111053 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ondition The `DETACH TABLE ... PERMANENTLY` client call alone is not a sufficient gate: `clickhouse-test` runs `.sh` tests under plain `bash`, so if the call fails (e.g. a stress-test server restart lands on it), the script would keep running and mutate a table directory that may still be attached, re-opening the `txn_version.txt` corruption race. Verify that the table is absent from `system.tables` and present in `system.detached_tables` with `is_permanently = 1`, and fail fast before touching anything under the table's data path. ClickHouse#111055
…ress-restart Detach tables permanently in part-loading-tree rollback tests
…_tree_rollback_startup_recovery` Two review comments on ClickHouse#111055 arrived shortly before the merge and were not addressed there: - The plain `DROP TABLE IF EXISTS` at startup silently does nothing on a table leaked in the permanently detached state by a previous run that was killed before its `EXIT` trap ran, while the leftover name still blocks `CREATE TABLE`. Call `recover_leaked_table` at startup instead, mirroring the rollback tests' `cleanup`. - The test fabricated a corrupt `txn_version.txt` right after `DETACH TABLE ... PERMANENTLY` without verifying the detach postcondition. Under stress a restart can land on the detach and, under plain `bash`, the script would fall through and write into a still-attached table's directory. Add the same fail-fast gate on `system.tables` / `system.detached_tables` with `is_permanently = 1` that the four rollback tests use. Co-Authored-By: Claude Fable 5 <[email protected]>
Description
Since 2026-07-19, stress test runs across sanitizers fail with
Cannot start clickhouse-server: the server cannot load the table created by one of thepart_loading_tree_rollbacktests (04241_part_loading_tree_rollback_contains,04063_part_loading_tree_rollback_reparent,04417_part_loading_tree_rollback_evict_reinsert_contains,04500_part_loading_tree_rollback_tmp_metadata) because its fabricated transaction metadata is corrupted, throwingCannot parse inputfromVersionInfo::readFromMultiLineBuffer(orPart ... intersects previous part ... and the transaction metadata of at least one of them could not be read) at startup. This hits master and many unrelated PRs.These tests fabricate part directories out-of-band (
cp -r,printf > txn_version.txt.tmp,mv) while the table is only non-permanentlyDETACH-ed. Stress tests restart the server at arbitrary moments; a plainDETACHdoes not survive a restart, so the table is loaded again at startup while the script is still fabricating files inside its data directory, and the server's version-metadata machinery (VersionMetadataOnDisk) races with the script on the sametxn_version.txt(.tmp)files, leaving corrupted metadata behind. Once corrupted, every subsequent server start fails, failing the whole stress run.Fix:
DETACH TABLE ... PERMANENTLYin all four tests of the family, which keeps the table detached across restarts; the explicitATTACH TABLEin the tests still re-attaches it.Additionally (per review), the detach client call alone is not a sufficient gate: the scripts run under plain
bash, so a failed detach (e.g. a restart landing on it) would fall through into the file-fabrication block. Each test now verifies the detach postcondition — the table is absent fromsystem.tablesand present insystem.detached_tableswithis_permanently = 1— and fails fast before touching anything under the table's data path.Also per review,
cleanupnow handles a permanently detached table:DROP TABLE IF EXISTSsilently does nothing on it while its name still blocksCREATE TABLE, so on failure paths that exit beforeATTACH TABLEsucceeds the table used to leak for the rest of the run. If the table is still detached,cleanupfirst removes the fabricated part directories (whose transaction metadata is exactly what could have madeATTACHthrow), re-attaches the table, and then drops it.Closes: #111053
Caused by: #100992
Related: #110246
Related: #109004
Example report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110246&sha=72768ce112527547fd077031893e6c2c7404b30f&name_0=PR&name_1=Stress%20test%20%28arm_msan%29
Example report (
04417, on #109004): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109004&sha=e26111dca401681dbc6b4ba4a9c42b6fe23a4a36&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29Changelog category (leave one):