Repository navigation
Harden 04624_part_loading_tree_rollback_startup_recovery against stress restarts and leaked tables - #111661
Conversation
…back_startup_recovery` Two review comments on #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]>
|
Workflow [PR], commit [47763e4] Summary: ✅ AI ReviewSummaryThis follow-up switches Findings
Final VerdictStatus: |
| DETACHED=$($CLICKHOUSE_CLIENT -q " | ||
| SELECT (SELECT count() FROM system.tables | ||
| WHERE database = currentDatabase() AND name = '${TABLE}') = 0 | ||
| AND (SELECT count() FROM system.detached_tables | ||
| WHERE database = currentDatabase() AND table = '${TABLE}' AND is_permanently) = 1 | ||
| ") | ||
| if [ "${DETACHED}" != "1" ]; then | ||
| echo "FAIL: table ${TABLE} is not detached permanently, refusing to modify its data directory" | ||
| exit 1 |
There was a problem hiding this comment.
If the stress restart lands on the earlier INSERT INTO ${TABLE} VALUES (42) or SELECT data_paths[1] client call, this new postcondition can still become 1 and we then enter the cp/printf block with a missing source part or an empty DATA_PATH. Under plain bash those filesystem commands fail silently, recover_leaked_table later re-attaches a healthy detached table, and the test still prints the reference 1 / 0 / 0 / OK without ever creating the corrupted txn_version.txt it is supposed to recover from.
To actually harden the test against restarts, please prove the path/source precondition too: derive DATA_PATH only after this check from system.detached_tables.uuid + system.disks, and fail unless ${DATA_PATH}all_1_1_0 exists before the out-of-band copy.
There was a problem hiding this comment.
Addressed in a follow-up, since this PR is already merged: #111730 derives DATA_PATH only after the detach gate, from system.detached_tables.uuid + system.disks (the same way recover_leaked_table does), and fails fast unless the source part ${DATA_PATH}all_1_1_0 exists before the out-of-band copy.
|
Another data point for this test family: on #110886 (head The permanent-detach gate from #111055 is in that branch, so the stress restart appears to have landed in a window it does not cover — plausibly after the final successful |
…tree_rollback_startup_recovery` Follow-up to ClickHouse#111661, addressing the remaining review comment: the detach-postcondition gate alone did not prove that the copy source exists. If a stress-test restart lands on the earlier `INSERT` or on the `SELECT data_paths[1]` client call, the gate could still pass while `DATA_PATH` is empty or the part `all_1_1_0` is missing; under plain `bash` the `cp`/`printf` would fail silently and the test would print the reference output without ever fabricating the corrupted `txn_version.txt` it is supposed to recover from. Now `DATA_PATH` is derived only after the gate, from `system.detached_tables.uuid` and `system.disks` (the same way `recover_leaked_table` does), and the test fails fast unless the source part directory exists before the out-of-band copy. 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]>
…04624-gate-and-startup-recovery Harden `04624_part_loading_tree_rollback_startup_recovery` against stress restarts and leaked tables
…tree_rollback_startup_recovery` Follow-up to ClickHouse#111661, addressing the remaining review comment: the detach-postcondition gate alone did not prove that the copy source exists. If a stress-test restart lands on the earlier `INSERT` or on the `SELECT data_paths[1]` client call, the gate could still pass while `DATA_PATH` is empty or the part `all_1_1_0` is missing; under plain `bash` the `cp`/`printf` would fail silently and the test would print the reference output without ever fabricating the corrupted `txn_version.txt` it is supposed to recover from. Now `DATA_PATH` is derived only after the gate, from `system.detached_tables.uuid` and `system.disks` (the same way `recover_leaked_table` does), and the test fails fast unless the source part directory exists before the out-of-band copy. Co-Authored-By: Claude Fable 5 <[email protected]>
Description
Follow-up to #111055, addressing two review comments on the regression test
04624_part_loading_tree_rollback_startup_recovery.shthat arrived shortly before that PR was merged:The plain
DROP TABLE IF EXISTSat startup silently does nothing on a table leaked in the permanently detached state by a previous run that was hard-killed before itsEXITtrap ran, while the leftover name still blocks the followingCREATE TABLE. The test now callsrecover_leaked_tableonce at startup, mirroring thecleanupof the fourpart_loading_tree_rollbacktests.The test fabricated a corrupt
txn_version.txtright afterDETACH TABLE ... PERMANENTLYwithout verifying the detach postcondition. Under stress a restart can land on the detach and, under plainbash, the script would fall through and write into a still-attached table's directory — the exact metadata corruption Detach tables permanently in part-loading-tree rollback tests #111055 fixes. The test now verifies the same fail-fast gate as the four rollback tests: the table is absent fromsystem.tablesand present insystem.detached_tableswithis_permanently = 1before anything underDATA_PATHis touched.The test output is unchanged; it passes locally against a 26.7.1 server.
Related: #111055
Changelog category (leave one):
Version info
26.8.1.60(included in26.8and later)