Repository navigation
Make 05054_embedded_rocksdb_explicit_dir_file_grant stress-restart safe - #118220
PedroTadim merged 3 commits into
Conversation
`Stress test (*)` loses the whole job on this test: the post-stress restart cannot attach `<db>_poc_<pid>.leak` (`Code: 555. Failed to open rocksdb path ... /CURRENT: No such file or directory`) and gives up after 11 attempts. `StorageEmbeddedRocksDB::drop` closes the handle but never removes an explicit `rocksdb_dir`, so this test removes its own. It removed them unconditionally, discarding the teardown drops' exit codes, and `stress.py` SIGTERMs a random `clickhouse-client` whose pgrep pattern does not match the test script itself, so the script outlives its dead client and still runs the `rm -rf`. `prepare_for_hung_check` only detaches databases, so `leak.sql` reaches the final restart, where `FORCE_ATTACH` skips `fs::create_directories` and `OpenForReadOnly` cannot open a directory that is gone. Whether that aborts startup or is instead deferred to the first query that waits on the table depends on `async_load_databases`, which the stress runner randomizes. Order the removal after proof that no stored definition still names those directories: capture both teardown drops' exit codes and gate the `rm -rf` on both. A zero status then has to mean the drop happened, so the two top-level `DROP TABLE`s carry `ignore_drop_queries_probability = 0`. `Stress test` injects `0.2`, and `InterpreterDropQuery` then silently skips such a drop for a table whose `storesDataOnDisk` is true, while returning success. The `DROP DATABASE` is deliberately not pinned. `InterpreterDropQuery` computes `is_drop_or_detach_database` from the top-level query and requires it to be false before skipping, so a table drop performed as part of a `DROP DATABASE` is never skipped. That carve-out is deliberate: `f1c0f886d5b60fb` added it because a partial skip left "orphaned tables that prevent server restart". A pin there would be a no-op, so the source comment states the rule scoped to what the setting actually does. Pinning the `RESTORE` arm's drop also removes a latent per-stress-run failure of the test itself: a skipped drop leaves the name taken, so the denial arm that follows prints `CREATED ANYWAY (unexpected)`. Measured at the injected `0.2` it reds 1 run in 20, and at `1.0` it reds every run. Only a `read_only` table is a restart carrier. A writable one reaches `rocksdb::DB::Open`, which is configured with `create_if_missing`, so it re-creates an empty directory instead of failing to attach.
`victim_rc == 0` means the drop happened only while `ignore_drop_queries_probability = 0` is in force on that statement. `InterpreterDropQuery` skips a top-level `DROP TABLE` of a table whose `storesDataOnDisk` is true and returns success, so if that pin ever stopped applying, the teardown would delete `SECRET_DIR` while a live table still named it and nothing would say so: the victim is writable, so the next start re-creates an empty RocksDB instead of failing to attach, and the reference ends before the teardown. Probe `EXISTS TABLE` after the drop, print on the contradiction, and require the probe in the gate as well. A probe that fails is not read as absence, so a teardown whose client died still removes nothing and prints nothing. Measured through `tests/clickhouse-test` at probability 1.0: with the pin removed the test now fails on one added line and keeps all three directories, where the same mutation was green with the directories removed. Also drop the claim that a table failing to attach aborts metadata loading. `async_load_databases` defaults to true, and there the failed load job is rethrown to the query that waits on the table; only the stress runner's randomized false arm refuses to start. The removal ordering that comment is attached to holds either way. Co-Authored-By: Claude Opus 5 <[email protected]>
`prepare_for_hung_check` fires `DETACH DATABASE` for every database without waiting for it, and the stress harness then says outright that shell scripts outlive `clickhouse-test` and keep issuing queries. A teardown reaching that window gets success from two drops that deleted nothing: with `IF EXISTS`, `tryGetDatabase` and `tryGetDatabaseAndTable` return null for an object missing from the catalog and the interpreter returns an empty result, while the metadata directory survives untouched. `EXISTS TABLE` reads `isTableExist`, false for a detached object as well, so no probe can tell the two apart. The absence of `IF EXISTS` is the only discriminator: the drop then throws `UNKNOWN_DATABASE`, which is exactly what the gate needs to mean "not verifiably deleted". Measured on this test, server alive throughout and no client killed: before, all four gate conditions passed, `SECRET_DIR` was removed and the next start refused to boot with `Code: 555 Failed to open rocksdb path ... /CURRENT: No such file or directory: Cannot attach table poc.leak`; after, the drop reports 81, the directories stay and the restart brings `leak` back reading `marker secret`. The same holds one level down for the victim's own database. Discard both drops' output: `clickhouse-test` fails a shell test on any non-empty stderr regardless of exit code, so a teardown landing in that window would turn this test red instead of leaking. Verified in both directions through the runner - green with the redirects, `having stderror:` without them. Name both arms in the teardown comment. A definition whose `rocksdb_dir` is gone cannot be attached only when it is `read_only`; a writable one comes back silently empty, which is measurable here as the victim losing its row across a restart, and two of the gate's four conditions exist for exactly that table. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model reviewThree rounds. Six findings agreed and fixed before publishing, none dismissed; the last round's ❌ The gate could still delete the directories while detached metadata named them. The stress ❌ Nothing detected the victim pin declining. With the pin gone the injector skips the drop, ❌ Two comment over-claims. A failed attach was said to always abort startup: 💡 Two nits raised in the last round and refuted at source rather than changed. The
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260905-055300 |
|
Workflow [PR], commit [967cf2e] Summary: ✅ AI ReviewSummaryThe PR hardens Final Verdict
|
|
cc @hanfei1991, could you review this? It is the same class as #107858 which you merged: a stress restart cannot attach an |
51ec619
…le_grant stress-restart safe
Backport #118220 to 26.8: Make 05054_embedded_rocksdb_explicit_dir_file_grant stress-restart safe
…le_grant stress-restart safe
Backport #118220 to 26.6: Make 05054_embedded_rocksdb_explicit_dir_file_grant stress-restart safe
Backport #118220 to 26.3: Make 05054_embedded_rocksdb_explicit_dir_file_grant stress-restart safe
Backport #118220 to 26.7: Make 05054_embedded_rocksdb_explicit_dir_file_grant stress-restart safe
…cit_dir_file_grant stress-restart safe
…cit_dir_file_grant stress-restart safe
Related: #117665
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Stress test (*)loses the whole job: the post-stress restart cannot attach<db>_poc_<pid>.leak(Code: 555 ... /CURRENT: No such file or directory). 8 rows in 3 days: 2 unrelated PRs, 6 release-branch runs, all after the reland.Dropping an
EmbeddedRocksDBtable with an explicitrocksdb_dircloses the handle but leaves the directory, so this test removes its own.stress.pySIGTERMs a randomclickhouse-clientwhose pattern misses the test script, so the script outlives its dead client and still runs therm -rf;prepare_for_hung_checkthen only detaches databases, soleak.sqlreaches the final restart, whereFORCE_ATTACHskipsfs::create_directoriesandOpenForReadOnlyfails on the missing directory.The
rm -rfruns only if both teardown drops reported success and a probe confirms the victim is gone: nothing is removed while a stored definition still names it. Two things make a zero status mean the drop happened: the top-levelDROP TABLEs pinignore_drop_queries_probability = 0, becauseStress testinjects0.2andInterpreterDropQuerythen skips a disk-backed table's drop, reporting success; and neither teardown drop saysIF EXISTS, which reports success for a merely detached object. Their stderr is discarded: any stderr fails a test.DROP DATABASEneeds no pin, the skip being disabled inside one. TheRESTOREpin also removes a latent per-run failure.Teardown extracted verbatim: unfixed, the directories go and the restart fails; fixed, they stay and it starts,
leakreadable. Measured with the client killed and with the databases detached. Removing either pin reds a mutant, as does dropping the redirect. 41 randomized runs, 20 under the injected client option: green, nothing left behind.Not fixed here: at
FORCE_ATTACHaread_onlytable whose directory has vanished still cannot attach, and withasync_load_databases = falsethat aborts startup, though the level's contract is to ignore errors. Pre-existing, reachable viatruncate()alone.CIDB breadth query and result
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=26.3&sha=0d1d84363d80aab0cb154b6d670bd50f7ec5a528&name_0=ReleaseBranchCI&name_1=Stress%20test%20%28amd_debug%29
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=26.3&sha=3e4f263a8de732250e07b36e12a90d5607d17110&name_0=ReleaseBranchCI&name_1=Stress%20test%20%28arm_asan%2C%20s3%29
Workflow [PR]
Sync PR [sync-upstream/pr/118220]
Version info
26.9.1.802(included in26.9and later)26.8.3.62,26.7.7.52,26.6.5.79,26.3.33.18