Repository navigation
Load a Filesystem database whose directory is gone instead of refusing to start - #118684
Conversation
…g to start
`DatabaseFilesystem`'s constructor validated the existence of its backing
directory unconditionally. Server startup rebuilds every database by replaying
its stored `ATTACH DATABASE` statement (`loadDatabase` -> `executeCreateQuery`
-> `InterpreterCreateQuery` -> `DatabaseFactory::get` -> that constructor),
`loadMetadata` aborts on the first exception, and nothing catches around the
factory call. A directory removed after the database was created therefore made
the server refuse to start, recoverable only by hand-editing `metadata/`, with
no SQL escape hatch because the server never accepts a connection.
Skip the existence check only for an internal metadata replay,
`args.internal && args.mode >= LoadingStrictnessLevel::ATTACH`. This is the
predicate `DatabaseDataLake`, `DatabasePostgreSQL` and
`DatabaseMaterializedPostgreSQL` already use for the same requirement.
`isLoadingFromExistingMetadata` is the trap here: it matches only
`FORCE_ATTACH`/`FORCE_RESTORE`, and a database replay uses plain `ATTACH`
because `loadDatabase` passes `create = true`, so `setForceAttach(true)` is
never reached. A regression arm covers that distinction, and building the fix
with the narrower helper leaves the original failure in place.
Deferring the check into `beforeLoadingMetadata` (as `DatabaseBackup` and
`DatabaseReplicated` do) is unavailable: `supportsLoadingInTopologicalOrder()`
is false for this engine, so `TablesLoader` takes the `loadStoredObjects`
branch and never calls it. Deleting the check outright was rejected because it
would silently accept `Filesystem('/nonexistent')` from a user and break
`02722_database_filesystem`.
A tolerated database exposes no tables, since every table resolves its file on
access, and it can still be inspected and dropped. `DatabaseFilesystem` was the
only path-backed database engine that hard-failed on an unreachable location:
`DatabaseS3` does no validation, `DatabaseHDFS` checks URL syntax only, and
`DatabaseURL` checks only that a scheme is present. The `user_files`
containment check is deliberately left fail-closed on replay, because it is a
security boundary and `checkTableFilePath` re-checks containment per table
regardless of `throw_on_error`.
The failure was first observed as `Cannot start clickhouse-server` in a
`Stress test (arm_tsan)` job, where a SIGKILL landing between a test's
`DROP DATABASE` and its `rm -rf` of the directory leaves the metadata file
behind. No test is changed to accommodate this; the removal is required for
that test's re-runnability.
Co-Authored-By: Claude Opus 5 <[email protected]>
…the comment `05136_database_filesystem_missing_path_on_load` sent the second `clickhouse local` invocation's stderr to `/dev/null`, which discarded the only text that identifies the defect: without it a base-build failure is a bare missing-lines stdout diff, on the sole regression test for a "server cannot start" fix. The redirect suppressed nothing that a green run emits. A bare `clickhouse local` sets `logger.level` to `fatal` unless one of `logger.console`, `logger.level`, `log-level` or `logger.log` is given, so the tolerated path's `LOG_WARNING` never reaches stderr; `shell_config.sh` builds `--send_logs_level` into `CLICKHOUSE_CLIENT` only, never into `CLICKHOUSE_LOCAL`; and the first invocation in the same test already ran unredirected. Measured after removing it: stderr is empty on the fix build and 50 randomized runs stay green, while the base build now reports `Code: 36 ... Path does not exist: ... while loading database ... from file metadata/fsdb.sql. (BAD_ARGUMENTS)`. Also reword the second sentence of the `is_internal_metadata_replay` comment. It justified the exclusion by who supplies the path, which is false for the short `ATTACH DATABASE db` form: that reads `metadata/<db>.sql`, replays the stored definition and supplies no path of its own, yet still throws, because `args.internal` is false. Name the discriminator that actually decides it. `RESTORE` is internal too and is excluded by the mode term instead, so the wording claims only what the guard does. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118377&sha=58f7c10d1c3a06e4661e9b38aa3d45dc6b268a96&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29 ClickHouse#118377 Co-Authored-By: Claude Opus 5 <[email protected]>
…ssing path
The previous commit's guard was `args.internal && args.mode >= ATTACH`, on the
assumption that `internal` means the server generated the statement. It does
not. `InterpreterParallelWithQuery::executeSubquery` runs every `PARALLEL WITH`
child through `executeQuery(..., QueryFlags{ .internal = true })`, and
`InterpreterExecuteAsQuery::execute` does the same for `EXECUTE AS`, so a
statement a user writes arrives at `DatabaseFactory` with `internal` set.
`PARALLEL WITH` is gated by no setting and DDL children are its canonical use.
Measured on a server: `ATTACH DATABASE d ENGINE = Filesystem('<missing>')` is
rejected with `Code: 36`, while the same statement followed by
`PARALLEL WITH DROP TABLE IF EXISTS <absent>` was accepted, wrote
`metadata/d.sql`, and survived a restart. Both plain forms already threw, so
only the wrapped form reached the tolerant branch.
Add a third conjunct, `args.replays_stored_definition`, computed by the
interpreter one line above the factory call as `create.attach &&
!need_write_metadata`. That expression already means "the definition being
attached is the one stored in `metadata/`", so this reuses the interpreter's own
answer instead of inventing a second notion of replay. A definition supplied
with the query is never a stored one, wrapper or not. The change moves in one
direction only: strictly fewer statements reach the tolerant branch, and a
genuine startup replay still evaluates all three terms true, which
`05136_database_filesystem_missing_path_on_load` continues to assert.
`02921_database_filesystem_path_check` gains the wrapped `ATTACH` arm. Its
sibling is `DROP TABLE IF EXISTS`, whose pipeline is empty, so the assertion
does not depend on the order the children run in or on what `max_threads`
randomizes to. Dropping the new conjunct while keeping the plumbing reddens
that arm with `The query succeeded but the server error '36' was expected`.
The sibling engines that share the two-term predicate are left alone: the same
laundering reaches them, but that belongs with the wrapper rather than with each
engine.
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118377&sha=58f7c10d1c3a06e4661e9b38aa3d45dc6b268a96&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29
ClickHouse#118377
Co-Authored-By: Claude Opus 5 <[email protected]>
The previous commit's third conjunct was `create.attach && !need_write_metadata`,
which it described as "the definition being attached is the one stored in
`metadata/`". It does not test that. `need_write_metadata` is
`!create.attach || !existsFile(metadata/<name>.sql)`, so the conjunct only tests
whether the NAME already has a stored definition; whether the definition being
executed came from that file is never checked. The file is read solely in the
short-syntax branch (`!create.storage && create.attach`), which a long-syntax
`ATTACH DATABASE ... ENGINE = ...` skips. `DETACH DATABASE` leaves the metadata
file in place (`DatabaseCatalog` removes it only when dropping, and
`DatabaseFilesystem::shouldBeEmptyOnDetach()` is false), so two ordinary
statements arrange the precondition.
Measured on a server, twice, with `buildId()` asserted against the binary:
CREATE DATABASE d;
DETACH DATABASE d;
ATTACH DATABASE d ENGINE = Filesystem('<missing>')
PARALLEL WITH DROP TABLE IF EXISTS <absent>;
was accepted, and `system.databases` then reported `d` with engine `Filesystem`
over a path that does not exist, while `metadata/d.sql` still held the original
`ENGINE = Atomic` definition. The same shape via short syntax, after removing
the directory of a real `Filesystem` database, was likewise accepted. Both plain
forms threw `Code: 36`, so `internal`, laundered by the wrapper, was again the
term being defeated.
Feed the decision from the loader instead of deriving it from the statement.
`InterpreterCreateQuery` gains `setIsMetadataReplay`, called only from
`executeCreateQuery` in `loadMetadata.cpp`, beside the `setInternal(true)` that
startup metadata replay already performs. Nothing else can reach it: `QueryFlags`
has no route to an interpreter member, so no SQL sets it. A dedicated flag rather
than the adjacent `setLoadDatabaseWithoutTables` because that one means "defer
table loading", not "this is a replay".
With the loader answering directly, `args.internal` leaves the predicate: the
same call site sets both, so it decided nothing. `args.mode >= ATTACH` is kept as
the idiom the sibling engines use; it is not independently provable by mutation
here, because a replayed `Filesystem` definition is always an `ATTACH DATABASE`
statement and therefore always that mode.
`isLoadingFromExistingMetadata` remains unusable for this: a database is replayed
under plain `ATTACH`, unlike tables, which use `FORCE_ATTACH`, so the helper never
matches a database load.
`02921_database_filesystem_path_check` gains the name-aliasing arm in pure SQL,
and re-attaches before dropping, since a database left detached keeps a metadata
file that every later start replays. `05136_database_filesystem_missing_path_on_load`
gains the sharper arm: the definition a start has just replayed is refused to a
user who replays it by hand, plainly and wrapped, and the start after each
rejection attaches the database again. Restoring the previous predicate reddens
both arms, the wrapped `05136` line flipping while its plain line stays green,
which is exactly the statement class that was reachable before.
The sibling engines that share the two-term predicate are still left alone: the
laundering reaches them too, and belongs with the wrapper rather than with each
engine.
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118377&sha=58f7c10d1c3a06e4661e9b38aa3d45dc6b268a96&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29
ClickHouse#118377
Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review - 2 blockers found and fixed over 3 rounds; 1 note on overlap with #116260 (click to expand)An independent model reviewed the resulting code cold, without the implementation notes, and a
The remedy for 1 and 2 is what the diff now does: the tolerance is keyed on a flag the loader sets Note for merge sequencing. My open #116260 threads an equivalent loader-set flag through the same Known residual, disclosed rather than fixed: the |
Pre-PR validation gate (click to expand)
Mutation testing (the guard was mutated, never deleted), each leg rebuilt and its
Noticed while reading nearby code, not addressed here and not otherwise raised: Session id: cron:clickhouse-impl-slot-4:20260907-221300 |
|
cc @tuanpach @tavplubix, could you review this? Startup replays every stored |
|
Workflow [PR], commit [a46be7a] Summary: ✅
AI ReviewSummaryThis PR fixes the original Findings❌ Blockers
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit a46be7a.
Changed lines: Changed C/C++ lines covered: 40/42 (95.24%) · Uncovered code |
CI finish ledger - 765654bEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260908-013052 |
| /// True when the database is created by the server itself (e.g. loading metadata on startup) rather | ||
| /// than by a user query. Lets an engine distinguish an internal reload from a user `ATTACH DATABASE`. | ||
| bool internal = false; | ||
| /// True only when the server replays a definition it stored itself, during startup metadata loading. |
There was a problem hiding this comment.
Filesystem now gets the right discriminator, but the shared invariant is still broken for the other external database engines that use the same startup-only exception. InterpreterParallelWithQuery::executeSubquery and InterpreterExecuteAsQuery::execute both rerun a user-authored ATTACH DATABASE with QueryFlags{ .internal = true }, and InterpreterCreateQuery::createDatabase forwards that bit here while is_metadata_replay stays false. DatabasePostgreSQL.cpp:715, DatabaseMaterializedPostgreSQL.cpp:786 / 818, and DatabaseDataLake.cpp:1688 still key their relaxed path on args.internal && args.mode >= LoadingStrictnessLevel::ATTACH, so the same wrapped ATTACH DATABASE ... PARALLEL WITH ... / EXECUTE AS ... shape still bypasses their startup-only checks even though it is not a metadata replay. For the PostgreSQL engines that means a user can persist a database pointing at a host that remote_url_allow_hosts should reject, and MaterializedPostgreSQL also skips its single-address validation. I think those consumers need to switch to args.is_metadata_replay in the same change, otherwise this PR only closes the laundering hole for Filesystem.
There was a problem hiding this comment.
Agreed, and verified against the source here: InterpreterParallelWithQuery.cpp:125 and InterpreterExecuteAsQuery.cpp:129 both re-run a user-authored statement with QueryFlags{ .internal = true }, so args.internal && args.mode >= LoadingStrictnessLevel::ATTACH does not mean "the server is replaying its own metadata". That is precisely why this PR stopped keying on it: is_metadata_replay is written in exactly one place, by the loader (loadMetadata.cpp:86), so no statement, wrapped or not, can set it.
On the three sibling engines, the disagreement is only about which PR carries the conversion, not about whether it is owed. It is already written: #116260 converts DatabasePostgreSQL.cpp:715, DatabaseMaterializedPostgreSQL.cpp:786/818 and DatabaseDataLake.cpp:1688, and threads the same marker through the same DatabaseFactory::get/getImpl signatures, under the name loading_stored_metadata. Repeating those hunks here would put the same three files in both PRs and turn a clean rebase into a conflict for whichever merges second.
Sequencing, so it does not need chasing: whichever of the two merges first keeps its flag name, the other rebases onto it and drops its own, so the tree ends with one marker rather than two. If #116260 stalls, or if reviewers would rather the siblings move with this fix, I will bring those hunks here and drop them from #116260 instead. I have added the residual to this PR's description so it is visible at merge time and not only in this thread.
This PR changes no sibling behaviour: all three predicates are byte-identical to master.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units49 translation units recompiled, 369 s compile time in total, 49 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Very minor, and maybe an overkill. Still passable.
|
Need to backport this to fix CI in release branches |
|
The three older backports of this PR cannot be built or applied as the robot produced them. I measured all four arms:
Cause on 26.6 and 26.7: this PR gave The remedy is one line on each of those branches:
26.3 is a different problem. Its I am not hand-authoring backport content: @ pufit's standing rule keeps that with the maintainers, and a fix pushed to the |
Backport #118684 to 26.8: Load a `Filesystem` database whose directory is gone instead of refusing to start
ReproducerShell reproducer — set #!/bin/bash
BIN="${BIN:-./clickhouse}" # path to the ClickHouse binary under test
# PR #118684 — a `Filesystem` database whose backing directory was removed makes the
# startup metadata replay throw BAD_ARGUMENTS, so the server/clickhouse-local refuses
set -uo pipefail
D=$(mktemp -d /tmp/repro_118684_XXXXXX)
trap 'rm -rf "$D"' EXIT
mkdir -p "$D/files"
out1=$(timeout 60 "$BIN" local --path "$D/store" -q "CREATE DATABASE fsdb ENGINE = Filesystem('$D/files'); SELECT name FROM system.databases WHERE name = 'fsdb'" 2>&1)
rc1=$?
echo "== run 1: create over an existing directory (rc=$rc1) =="
echo "$out1"
[ "$rc1" = "124" ] && { echo "TIMEOUT on run 1"; exit 2; }
if [ "$rc1" != "0" ] || ! echo "$out1" | grep -q "^fsdb$"; then
echo "INCONCLUSIVE: this build cannot create ENGINE = Filesystem over --path metadata"
exit 2
fi
rm -rf "$D/files"
out2=$(timeout 60 "$BIN" local --path "$D/store" -q "SELECT name FROM system.databases WHERE name = 'fsdb'" 2>&1)
rc2=$?
echo "== run 2: same store, directory removed (rc=$rc2) =="
echo "$out2"
[ "$rc2" = "124" ] && { echo "TIMEOUT on run 2"; exit 2; }
if echo "$out2" | grep -q "Path does not exist"; then
echo "BUG: metadata replay of the stored ATTACH DATABASE throws, nothing starts"
exit 1
fi
if echo "$out2" | grep -q "^fsdb$"; then
echo "CLEAN: database loaded without its directory"
exit 0
fi
echo "INCONCLUSIVE: unexpected run-2 output"
exit 2Results:
Backport the fix to CC component owner: @alexey-milovidov @scanhex12 Analysis metadata
Introducing change: not identified
|
#118684 gave `DatabaseFilesystem`'s constructor a fourth parameter with no default value. On master the factory in `DatabaseFilesystem.cpp` is the only place that constructs one, so the change compiles there. This branch still has a second call site that master no longer has: `createClickHouseLocalDatabaseOverlay` in `programs/local/LocalServer.cpp`, which master rewrote to register a `DatabaseURL` over `file://` instead, in a change that was never backported. Every build job failed on it, each with a single error: programs/local/LocalServer.cpp: note: in instantiation of function template specialization 'std::make_shared<DB::DatabaseFilesystem, const std::string &, const char (&)[1], std::shared_ptr<const DB::Context> &, 0>' requested here allocator_traits.h:302:5: error: no matching function for call to '__construct_at' Pass `false`, which keeps the behaviour this call site had. The flag only suppresses the `Path does not exist` refusal while the server replays its own stored metadata, and this overlay is registered fresh on every `clickhouse-local` start over an empty path, which resolves to the current directory. Adding a default argument to the declaration would also build, but it would leave the header differing from master's and would hand the permissive value to any call site added later. Naming the argument here keeps every ported file identical to master and states the choice at the one place that has to make it. 26.8 needs none of this: it already carries the `DatabaseURL` rewrite, which is why its backport merged green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#118684 gave `DatabaseFilesystem`'s constructor a fourth parameter with no default value. On master the factory in `DatabaseFilesystem.cpp` is the only place that constructs one, so the change compiles there. This branch still has a second call site that master no longer has: `createClickHouseLocalDatabaseOverlay` in `programs/local/LocalServer.cpp`, which master rewrote to register a `DatabaseURL` over `file://` instead, in a change that was never backported. Every build job failed on it, each with a single error: programs/local/LocalServer.cpp: note: in instantiation of function template specialization 'std::make_shared<DB::DatabaseFilesystem, const std::string &, const char (&)[1], std::shared_ptr<const DB::Context> &, 0>' requested here allocator_traits.h:302:5: error: no matching function for call to '__construct_at' Pass `false`, which keeps the behaviour this call site had. The flag only suppresses the `Path does not exist` refusal while the server replays its own stored metadata, and this overlay is registered fresh on every `clickhouse-local` start over an empty path, which resolves to the current directory. Adding a default argument to the declaration would also build, but it would leave the header differing from master's and would hand the permissive value to any call site added later. Naming the argument here keeps every ported file identical to master and states the choice at the one place that has to make it. 26.8 needs none of this: it already carries the `DatabaseURL` rewrite, which is why its backport merged green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…tory is gone Resolved four conflicts. Three of them are the same divergence: master threads an `internal` flag through `DatabaseFactory::get`, `getImpl` and `Arguments`, which this branch does not have, and #118684 adds `is_metadata_replay` alongside it. Only `is_metadata_replay` belongs to this backport, so it is threaded on its own here and the signatures keep their existing shape: get(create, metadata_path, context, mode, is_metadata_replay) getImpl(create, metadata_path, context, mode, is_metadata_replay) The incoming hunk around `getImpl` also carried `isDatabaseExternal`, a master-only function this branch never had; it is not part of #118684 and is left out. Nothing references it. The `Arguments` comment is reworded for the same reason, since the `internal` field it contrasts against does not exist in this struct here. The `internal` concept itself does still exist on `InterpreterCreateQuery`, so the comment in `DatabaseFilesystem.cpp` is master's, unchanged. The fourth conflict is `02921_database_filesystem_path_check.sql`, where master had renamed the fixed database name to `{CLICKHOUSE_DATABASE_1:Identifier}` before adding this PR's four arms. Taking master's file whole: both that substitution and `PARALLEL WITH` already work on this branch, so the arms run as written and the file stays identical to master. The reference file is unchanged. `clickhouse-local` here reaches `loadMetadata` exactly as master does, so the premise of the new `05136_database_filesystem_missing_path_on_load` holds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#118684 gave `DatabaseFilesystem`'s constructor a fourth parameter with no default value. On master the factory in `DatabaseFilesystem.cpp` is the only place that constructs one, so the change compiles there. This branch still has a second call site that master no longer has: `createClickHouseLocalDatabaseOverlay` in `programs/local/LocalServer.cpp`, which master rewrote to register a `DatabaseURL` over `file://` instead, in a change that was never backported. Every build job failed on it, each with a single error: programs/local/LocalServer.cpp: note: in instantiation of function template specialization 'std::make_shared<DB::DatabaseFilesystem, const std::string &, const char (&)[1], std::shared_ptr<const DB::Context> &, 0>' requested here allocator_traits.h:302:5: error: no matching function for call to '__construct_at' Pass `false`, which keeps the behaviour this call site had. The flag only suppresses the `Path does not exist` refusal while the server replays its own stored metadata, and this overlay is registered fresh on every `clickhouse-local` start over an empty path, which resolves to the current directory. Adding a default argument to the declaration would also build, but it would leave the header differing from master's and would hand the permissive value to any call site added later. Naming the argument here keeps every ported file identical to master and states the choice at the one place that has to make it. 26.8 needs none of this: it already carries the `DatabaseURL` rewrite, which is why its backport merged green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…y is gone instead of refusing to start
Backport #118684 to 26.6: Load a `Filesystem` database whose directory is gone instead of refusing to start
Backport #118684 to 26.7: Load a `Filesystem` database whose directory is gone instead of refusing to start
Backport #118684 to 26.3: Load a `Filesystem` database whose directory is gone instead of refusing to start
…e directory is gone instead of refusing to start
…e directory is gone instead of refusing to start
…e directory is gone instead of refusing to start
…e accessed The DatabaseFilesystem constructor probed its path with the throwing fs::exists and, on a server, with pathStartsWith (fs::relative, which canonicalizes). libc++ maps only ENOENT/ENOTDIR to "not found", so any other stat error (ELOOP, EACCES, ESTALE, EIO, ENAMETOOLONG) escaped as Code: 1001 STD_EXCEPTION before the startup-replay guard of ClickHouse#118684. loadMetadata stops at the first exception, so a server or a clickhouse-local --path store holding such a database refused to start, and the database could not be dropped. Probe once with fs::exists(path, ec). When stat works, containment keeps the canonical pathStartsWith check. When it fails, the path cannot be canonicalized, so containment is checked lexically with fileOrSymlinkPathStartsWith, the check every table resolution already uses, and a path outside user_files is still refused on replay. An unreachable path is then handled like a missing one: the replay logs the errno and attaches the database with no tables, and a user statement gets BAD_ARGUMENTS with the errno instead of STD_EXCEPTION. Missing and existing paths behave exactly as before. 05136 gains a symlink-loop restart sequence for clickhouse-local and two server arms with a component over NAME_MAX, inside and outside user_files. Closes ClickHouse#121705 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #118377
Related: #117895
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a server that refused to start after the directory backing a
Filesystemdatabase had been removed. Such a database is now loaded without tables and can be inspected and dropped, while aCREATE DATABASEorATTACH DATABASEissued by a user is still rejected when the path does not exist.Description
Stress test (arm_tsan)on #118377 could not start the server at all: all 11 start attempts died withCode: 36 ... Path does not exist: /var/lib/clickhouse/user_files/05057_..., thrown while loading databasefsdb_05057_.... Failing job: https://github.com/ClickHouse/ClickHouse/actions/runs/34118002382/job/101749188450Root cause.
DatabaseFilesystem's constructor validated the existence of its backing directory unconditionally. Startup rebuilds every database by replaying its storedATTACH DATABASEstatement, andloadMetadataaborts on the first exception. One removed directory therefore made the server unstartable, recoverable only by hand-editingmetadata/. Any user who createsENGINE = Filesystem(<dir>)and later removes<dir>reaches it.Change. The check is skipped, and a warning logged instead, only while the server replays its own stored metadata on start. The loader answers that directly:
InterpreterCreateQuery::setIsMetadataReplayis called only fromexecuteCreateQueryinloadMetadata.cpp, and no SQL can reach it. Neither substitute works here: notinternal, becausePARALLEL WITHandEXECUTE ASrun a user's children as internal queries, and notisLoadingFromExistingMetadata, because a database replay runs at plainATTACH(loadDatabasepassescreate = true, sosetForceAttachis never reached). A userCREATE/ATTACH DATABASEover a missing path is unchanged and still failsBAD_ARGUMENTS, and theuser_filescontainment check stays fail-closed even on replay. A tolerated database exposes no tables, since every table resolves its file on access, and drops normally.Validation. New
05136_database_filesystem_missing_path_on_loadremoves the directory between twoclickhouse local --pathinvocations over one store: it fails on master, passes here, and asserts the database returns on the next start while a hand-issued replay is still refused.02921_database_filesystem_path_checkgains four arms for the user-supplied and wrapper-wrapped forms. Both directions of the guard are mutation-covered.Not fixed here: the same startup-only relaxations in the PostgreSQL and DataLake database engines still key on
internal; #116260 converts those three sites.Reproduced first-party CI failure, and the deterministic local repro
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118377&sha=58f7c10d1c3a06e4661e9b38aa3d45dc6b268a96&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29
A stress-test SIGKILL landing between a test's
DROP DATABASEand itsrm -rfof thedirectory leaves the metadata file behind, so no test-side cleanup can prevent it.
Workflow [PR]
Sync PR [sync-upstream/pr/118684]
Version info
26.9.1.1315(included in26.9and later)26.8.3.102,26.7.8.5,26.6.6.3,26.3.33.71