Repository navigation
Use a designated directory in the home for clickhouse-local data by default - #116042
Conversation
…efault Previously, `clickhouse-local` used a unique temporary directory when `--path` was not specified, so the data did not survive between runs. Now it works with a designated directory for application data in the home directory by default (`$XDG_DATA_HOME/clickhouse-local` or `~/.local/share/clickhouse-local` on Linux, `~/Library/Application Support/clickhouse-local` on macOS), like a usual desktop application, and the data is persistent. The previous behavior is available with the new `--tmp` option. An explicit `--path` takes precedence over `--tmp`, so wrappers can pass `--tmp` as a baseline while individual invocations still redirect the data to an explicit location. Test wrappers and the report-building invocations of `clickhouse-local` in the performance comparison scripts pass `--tmp`, because they run in parallel and must not share (and lock) the default designated directory. Co-Authored-By: Claude Fable 5 <[email protected]>
The check runs the binary in ancient distribution containers only as a smoke test, so keep it independent of the HOME environment variable and of the new default designated data directory. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [5536a1f] Summary: ✅
AI ReviewSummaryPR #116042 makes Final Verdict✅ Approve |
When another instance already works with the same directory (the default designated directory in the home or an explicit `--path`), the error now suggests the `--tmp` and `--path` options, and also turning the already running instance into a server with `SYSTEM START LISTEN TCP` (connect with `clickhouse-client`) or `SYSTEM START LISTEN HTTP` (open `http://localhost:8123/play` in a web browser). Co-Authored-By: Claude Fable 5 <[email protected]>
…lt directory `$CLICKHOUSE_LOCAL` now expands to more than one word, so the tests that invoked it as `"$CLICKHOUSE_LOCAL"` tried to execute a file whose name contained the `--tmp` argument. Unquote those invocations. The `clickhouse-local` invocations that do not go through the test wrapper (the two `expect` tests, the DWARF query of `find_symbols.py`, and the WebAssembly smoke test) now pass `--tmp` explicitly, so that they keep using their own directory instead of sharing (and locking) the default designated directory in the home directory. Document the new default directory and the `--tmp` option.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units11 translation units recompiled, 41 s compile time in total, 11 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.09 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
…ell benchmarks `shell_env_for` in `tests/performance/scripts/perf.py` exported a bare `clickhouse local` to `<query type="shell">` benchmarks. With the new default data directory in the home, a benchmark that starts several `clickhouse-local` processes at once (`insert_direct_parallel.xml`) would fail with `Another server instance in same directory is already running`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…rapper
Integration tests, the Docker image smoke tests and the system-table docs
generator execute `clickhouse local` directly, so they now use the persistent
designated directory in the home. `test_distributed_format` broke because of
that: it runs `create table t ... engine = File('Distributed', ...)` inside
`clickhouse local`, the table survived the invocation, and every later
`clickhouse local` in the same container failed to attach it once the
underlying file was gone:
Code: 722. DB::Exception: Waited job failed: Code: 695. DB::Exception:
Load job 'load table default.t' failed: Code: 107. DB::ErrnoException:
Cannot open file .../shard1_all_replicas/1.bin ... (FILE_DOESNT_EXIST)
All of these invocations want a throwaway instance, so give them `--tmp`.
|
🕵 CI status after this push:
One thing that is worth a decision rather than a silent change: |
The default working directory sets `path` in the configuration so that the rest of the
startup treats it exactly like an explicit `--path`, but `processConfig` also branched on
`has("path")` to decide whether to attach the system tables, and the `no-system-tables`
check lived only in the `else if` branch. As a result a plain
`clickhouse-local --no-system-tables` silently ignored the option unless the caller also
passed `--tmp`.
Both branches now honor `no-system-tables`: neither the `system` database nor
`INFORMATION_SCHEMA` is attached, while the user's persisted tables are still loaded
(`loadMetadata` skips the system databases). The background tasks needed by DDL operations
like `DROP VIEW SYNC` are also created when there was no metadata to load yet, which is the
usual case on the first run in the default directory.
Test `05153_no_system_tables_with_default_local_path` covers the option in the default mode
with a private `HOME`.
…default directory `tests/config/install.sh` and `tests/docker_scripts/upgrade_runner.sh` probe `system.build_options` / `system.settings` with bare `clickhouse local` invocations. With the persistent default directory these first lock and load `~/.local/share/clickhouse-local`, so a table persisted there by an unrelated invocation, or a concurrent instance holding the directory, can make the probe fail instead of answering. Both scripts now ask for a throwaway directory with `--tmp`. The option does not exist in the previous-release binary of the upgrade check - which defaults to a temporary directory anyway - so `install.sh` asks the binary at hand whether it supports the option, and `upgrade_runner.sh` starts adding it only after the new packages are installed.
|
🕵 Addressed both remaining review findings and merged
CI on the previous push: @groeneai, please investigate the flaky The design question from my previous comment still stands: |
|
Investigated. This is not runner memory pressure: the sanitizer skip-probe in that test file inverts on this branch, and both failures in that job follow from it.
result = subprocess.run([binary, "local", "--query",
"SELECT value FROM system.build_options WHERE name = 'CXX_FLAGS'"], ...)
return "-fsanitize=" in result.stdout
except Exception:
return False
Measurements (CIDB, matched on
The probe therefore answers The fix is what this PR already does at every other call site. All 13 [
binary,
"local",
"--tmp",
"--query",On the separate PR: One optional point, your call: the probe turns any failure into |
…fault-path-home # Conflicts: # docker/keeper/Dockerfile.distroless # docker/server/Dockerfile.distroless # docker/server/Dockerfile.ubuntu # tests/config/install.sh # tests/integration/test_input_format_parallel_parsing_memory_tracking/test.py
…fault mode The skip probe runs `clickhouse local` without `--tmp`, so with the persistent default directory it failed inside the container and answered "not a sanitizer build". Under ASan the test then ran instead of being skipped, the page cache fell back to its 10 MiB floor and the assertion failed, and the second 20 GiB instance pushed the job over its memory budget. Pass `--tmp` like every other probe touched by this branch. Found by @groeneai on #116042 after https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116042&sha=c637dfc60e051bc7ce9d9c4507299f5ee3ec9bfd&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20targeted%29 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…on drop `clickhouse-local` now loads the persisted tables asynchronously, and the dependencies of a table on named collections (`NamedCollectionFactory`) and on definers (`DefinerDependencies`) are registered only when the table is constructed in its load job. `DROP NAMED COLLECTION` and `DROP USER` consult only these registries, so as the first statement of a new process they could drop an object that a persisted table or view still needs. Wait for the startup of all databases before checking the dependencies. The startup of a database ignores the failures of its tables, so a broken table does not prevent the drop. The same applies to the server with `async_load_databases`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged master to pick up the reverted default of |
|
🕵 All public CI checks are green. The only red check is |
|
@alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
|
@groeneai maybe you could fix it? |
|
I have a fix in #128088. This is not really flaky: since the test was added it failed in every |
…n with --tmp Since ClickHouse#116042, clickhouse local without --tmp or --path creates its data directory under $HOME/.local/share. praktika runs the performance comparison container as --user <uid>, which has no passwd entry in the image, so HOME=/ and creating /.local fails with "Code: 1001 ... Permission denied". ClickHouse#116042 converted most calls of the harness to --tmp but missed four: - s3_service.seed_catalog fails prepare_s3, so the nightly shard holding iceberg_rest_catalog.xml (Performance Comparison (arm_release, master_head, nightly, 4/4)) runs no tests since 2026-10-29. - The two reference GIT_HASH lookups in performance_tests.py (after Install Reference and in Build Report) return "" through the non-strict Shell.get_output, so PR perf results are uploaded with an empty old_sha. - compare.sh match_reference_debug_info gets empty line counts; its Python twin, which ClickHouse#116042 fixed, decides first, so this has no effect today. All four now use the existing --help probe: local_command() in Python and an equivalent local_tmp_option helper in compare.sh. --tmp is passed only when the binary lists it, because a reference build older than the option rejects it as an unrecognized argument. In compare.sh the probe reads --help through a process substitution: a pipeline would turn grep -q's early exit into a failure under pipefail, and an assignment would make set -x print the whole --help text into the log. --tmp keeps one throw-away directory per call, as before ClickHouse#116042. A writable HOME instead would share one persistent directory between calls; seed_catalog then fails on a re-run with DATABASE_ALREADY_EXISTS for database c. Validated in clickhouse/performance-comparison:8109f2886addf0c0b83f_amd run as CI runs it (--user, HOME=/), with master release builds from before and after ClickHouse#116042: the seed fails with the CI error before and passes twice after; the GIT_HASH lookup returns the commit after the change for both builds; the compare.sh probe returns line counts after the change, with --tmp only for the newer build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test writes a script whose first line is `#!<path>/clickhouse-local --queries-file` and executes it. That run has no `--tmp` and no `--path`, so since ClickHouse#116042 it uses the default data directory in the home (`~/.local/share/clickhouse-local`, or `$XDG_DATA_HOME/clickhouse-local`) and holds the `status` lock there. Any other run using the same directory at that moment makes one of them fail with `Code: 76 ... Cannot lock file .../status` (CANNOT_OPEN_FILE). Seen on master in `Stateless tests (amd_tsan, parallel)`. `--tmp` cannot be added to the shebang line: Linux passes everything after the interpreter path as a single argument. The environment is the only channel into that process, so the test gets a private HOME and an empty XDG_DATA_HOME, the same block ClickHouse#128197 added to 03134 and 03536. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…log_remove_part_on_retried_drop_table Since ClickHouse#116042 clickhouse-local loads persisted tables asynchronously, and a query waits only for the tables it uses. The second clickhouse-local of the test arms the ONCE failpoint disk_object_storage_fail_commit_metadata_transaction as its first statement, which does not use d.t. When the background job 'load table d.t' runs after the arm, the attach commits a metadata transaction on the local_blob_storage disk (DiskObjectStorage::createDirectories), consumes the failpoint and fails with FAULT_INJECTED; DROP TABLE d.t SYNC then waits on the failed load and throws ASYNC_LOAD_WAIT_FAILED (seen twice in Stateless tests (arm_binary, parallel), PRs 125006 and 129676). SYSTEM WAIT LOADING PARTS d.t resolves the table through DatabaseCatalog::getTable -> waitTableStarted, which waits for the load and startup jobs, so the DROP's part removal is again the first metadata commit after the arm. It prints nothing; the reference is unchanged. Validation on a master debug binary: with 3000 filler tables and tables_loader_background_pool_size = 1 the old test fails 9/10 (load still PENDING at the arm in every failing run), the fixed one passes 10/10; tests/clickhouse-test with random settings: 16/50 fail before, 50/50 and 300/300 pass after. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since ClickHouse 26.11 (PR ClickHouse/ClickHouse#116042), clickhouse-local keeps its databases in ~/.local/share/clickhouse-local by default, so the CREATE TABLE that ./query runs before every query fails with TABLE_ALREADY_EXISTS from the second query on. --tmp restores a temporary directory per run. It does not exist before 26.11, so merge this when 26.11 is released. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a home of their own Since ClickHouse#116042, clickhouse-local without --tmp or --path works in a designated directory in the home ($XDG_DATA_HOME/clickhouse-local or ~/.local/share/clickhouse-local; ~/Library/Application Support on macOS) and holds a lock on its `status` file for the whole run. That change gave $CLICKHOUSE_LOCAL a --tmp, but these three tests start clickhouse-local through the bare ${CLICKHOUSE_BINARY}, so all their local-mode runs in a CI job share the job's one default directory. When two of them overlap (two of these tests at the same time in a parallel job, or two copies of one test in the flaky check), the second fails with "Code: 76 ... Cannot lock file .../clickhouse-local/status". Seen on PR ClickHouse#124882 (03267, Stateless tests (amd_debug, parallel)) and PR ClickHouse#127774 (03536, Fast test). Prefix each local-mode line with a per-test HOME under CLICKHOUSE_TMP and an empty XDG_DATA_HOME (an absolute one wins over HOME on Linux), the same form ClickHouse#116042 uses in its own default-directory tests. The argv of every invocation is unchanged, so the dispatch rules of programs/main.cpp that these tests pin stay covered, including the no-argument rule that only 03267 exercises (`clickhouse < file`); --tmp would have turned that line into the dash-option rule. Client-mode lines and $CLICKHOUSE_LOCAL lines are untouched. Co-Authored-By: Claude Opus 5.5 <[email protected]>
By default (when
--pathis not specified),clickhouse-localnow works with a designated directory for application data inside the home directory, which is typical for applications on Linux and macOS, so tables and other data survive between runs:$XDG_DATA_HOME/clickhouse-localor~/.local/share/clickhouse-local;~/Library/Application Support/clickhouse-local.The directory is created with owner-only permissions, and it engages the same persistent behaviors as an explicit
--path: loading of the metadata, the persistent storage for access entities, and thestatusfile lock.The previous behavior (a unique temporary directory, removed on exit) is available with the new
--tmpoption. An explicit--pathtakes precedence over--tmp, so wrappers can pass--tmpas a baseline while individual invocations still redirect the data to an explicit location. When a second instance runs concurrently on the same directory (the default one or an explicit--path), the "another server instance in same directory is already running" error now suggests the ways out: the--tmpand--pathoptions, or turning the already running instance into a server withSYSTEM START LISTEN TCP(connect withclickhouse-client) orSYSTEM START LISTEN HTTP(openhttp://localhost:8123/playin a web browser).The test wrappers (
$CLICKHOUSE_LOCALintests/queries/shell_config.sh, the ASan detection inclickhouse-test), the report-building invocations ofclickhouse-localin the performance comparison scripts, and the compatibility check pass--tmp, because they run in parallel (or must stay independent ofHOME) and must not share and lock the default designated directory.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
By default (when
--pathis not specified),clickhouse-localnow stores its data in a designated directory inside the home directory ($XDG_DATA_HOME/clickhouse-localor~/.local/share/clickhouse-localon Linux,~/Library/Application Support/clickhouse-localon macOS), so the data survives between runs. The previous behavior of using a unique temporary directory that is removed on exit is available with the new--tmpoption. Only one instance can work with the same directory at a time: for concurrent instances, use--tmpor--path.Workflow [PR]
Sync PR [sync-upstream/pr/116042]
Version info
26.11.1.866-master(included in26.11and later)