Skip to content

Do not leave a Filesystem database pointing at a removed directory, which makes the server refuse to start - #119618

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-filesystem-database-test-leftover
Sep 13, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-filesystem-database-test-leftover

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

05153_database_filesystem_cache_read_on_file_grant creates a Filesystem database over a directory under user_files and removes both at the end. The two cleanups are not atomic and they fail independently: DROP DATABASE is a call into the server and fails whenever the server is gone — routine under a stress run, where the server is killed and restarted while the tests run — while rm -rd is local and always succeeds.

The database's metadata then outlives the directory it points at, and every later server start aborts while loading metadata:

Code: 36. DB::Exception: Path does not exist: /var/lib/clickhouse/user_files/d_05153_test_..._21520:
while loading database `db_05153_test_..._23401` from file metadata/db_05153_test_..._23401.sql. (BAD_ARGUMENTS)

so the server never comes back and the job fails with Cannot start clickhouse-server. Seen on Stress test (arm_asan_ubsan, s3): https://github.com/ClickHouse/ClickHouse/actions/runs/34678356221/job/103529922983 (report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116647&sha=fca3eb858cfcfc30c835375b45f976add5188544&name_0=PR&name_1=Stress%20test%20(arm_asan_ubsan,%20s3) , PR #116647 — the failure is unrelated to that pull request's changes).

The fix removes the directory only once the database that points at it is really gone. A dead server makes EXISTS DATABASE produce nothing, the directory is kept, and the leftover is a harmless empty directory instead of a server that cannot start. This mirrors what 05057_file_rename_after_processing_write_grant already does for the same hazard.

The other Filesystem database tests were checked and are not affected: 02722_database_filesystem and 04653_database_filesystem_concurrent_resolve create the database over the user_files root, which no test removes.

Verified on a local server: the test passes and leaves no directory behind, and EXISTS DATABASE answers 1 for a live database, 0 for a dropped one and nothing at all when the server is down.

Related: #116647

Documentation entry for user-facing changes

Changelog category (leave one):

  • CI Fix or improvement (changelog entry is not required)

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/119618]

Version info

  • Merged into: 26.9.1.1380 (included in 26.9 and later)
  • Backported to: 26.8.3.106, 26.7.7.94, 26.6.5.121, 26.3.33.70

`05153_database_filesystem_cache_read_on_file_grant` creates a `Filesystem`
database over a directory under `user_files` and then removes both, but the
two cleanups are not atomic and they fail independently: `DROP DATABASE` is a
call into the server and fails whenever the server is gone -- which is routine
under a stress run, where the server is killed and restarted while the tests
run -- while `rm -rd` is local and always succeeds.

The database's metadata then outlives the directory it points at, and every
later server start aborts while loading metadata:

    Code: 36. DB::Exception: Path does not exist:
    /var/lib/clickhouse/user_files/d_05153_test_..._21520: while loading
    database `db_05153_test_..._23401` from file metadata/....sql.
    (BAD_ARGUMENTS)

so the server never comes back and the job fails with `Cannot start
clickhouse-server`, as seen on
https://github.com/ClickHouse/ClickHouse/actions/runs/34678356221/job/103529922983
(`Stress test (arm_asan_ubsan, s3)`).

Remove the directory only once the database that points at it is really gone.
A dead server makes `EXISTS DATABASE` produce nothing, the directory is kept,
and the leftover is a harmless empty directory instead of a server that cannot
start. This mirrors what `05057_file_rename_after_processing_write_grant`
already does for the same hazard.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1bb1ed5]

Summary: ✅


AI Review

Summary

This PR changes the cleanup in 05153_database_filesystem_cache_read_on_file_grant.sh so the backing directory is removed only after the Filesystem database is confirmed absent. I reviewed the current diff, the DROP DATABASE / metadata-removal path, and the sibling Filesystem database tests that clean up temporary directories; I did not find a correctness or reliability issue that warrants an inline review comment.

Missing context / blind spots
  • ⚠️ I did not reproduce the original Stress test (arm_asan_ubsan, s3) failure locally, so this review is based on the current code path and catalog semantics rather than an end-to-end stress rerun.
Final Verdict

✅ No blocking issues found in the current diff.

@PedroTadim

Copy link
Copy Markdown
Member

Must backport this to fix CI

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Sep 13, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 13, 2026
Merged via the queue into master with commit 4758982 Sep 13, 2026
174 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-filesystem-database-test-leftover branch September 13, 2026 08:13
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 13, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 13, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 13, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 13, 2026
…ng at a removed directory, which makes the server refuse to start
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #119618 to 26.8: Do not leave a `Filesystem` database pointing at a removed directory, which makes the server refuse to start
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #119618 to 26.7: Do not leave a `Filesystem` database pointing at a removed directory, which makes the server refuse to start
PedroTadim added a commit that referenced this pull request Sep 13, 2026
Backport #119618 to 26.3: Do not leave a `Filesystem` database pointing at a removed directory, which makes the server refuse to start
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #119618 to 26.6: Do not leave a `Filesystem` database pointing at a removed directory, which makes the server refuse to start
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 18, 2026
…ase pointing at a removed directory, which makes the server refuse to start
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 18, 2026
…ase pointing at a removed directory, which makes the server refuse to start
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 18, 2026
…ase pointing at a removed directory, which makes the server refuse to start
@clickhouse-gh clickhouse-gh Bot added comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants