Commit Graph
1649 Commits
Author SHA1 Message Date
Anton Popov e3ceb4e141 Merge remote-tracking branch 'upstream/master' into HEAD 2026-03-02 12:26:51 +00:00
Alexey MilovidovandGitHub 1c7c44d587 Merge pull request #98232 from ClickHouse/jemalloc-setup-once
Make jemalloc profiling cover all threads when enabled
2026-03-02 03:48:51 +00:00
Antonio AndelicandClaude Opus 4.6 c527e0bb99 Fix Jemalloc::setup crash after watchdog fork in debug builds
The previous implementation used `std::call_once` which fired in the
parent process during `BaseDaemon::initialize`. After the watchdog
`fork`, jemalloc state (e.g. `background_thread`) resets in the child
but the `once_flag` remains set, so the verification check saw a
mismatch and fired `chassert`.

Split `setup` and `verifySetup` into separate functions:
- `setup` always applies settings (idempotent), called in
  `BaseDaemon::initialize` and re-applied after watchdog fork
- `verifySetup` checks jemalloc state matches server settings,
  called from `Server::main` and `Keeper::main`

Also extract config key names into constants in `Jemalloc.h` to keep
them in sync between `BaseDaemon` and `ServerSettings`.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98232&sha=b69293471789706abde22ec86f33104dbfaf0382&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-01 21:58:03 +01:00
Amos Bird a4cb6c38dd Allow custom http_handlers per protocol endpoint
Add optional <handlers> config key to type=http entries in <protocols>,
so each HTTP port can use a different set of http_handlers. This enables
use cases like running an alternative HTTP API (e.g. ES-compatible) on
a separate port with its own routing rules, without affecting the
default HTTP port.

Config example:
  <protocols>
    <alt_http>
      <type>http</type>
      <port>8124</port>
      <handlers>http_handlers_alt</handlers>
    </alt_http>
  </protocols>
  <http_handlers_alt>
    <rule>...</rule>
  </http_handlers_alt>

If <handlers> is omitted, the default <http_handlers> is used (fully
backward compatible). Config reload (updateServers) also respects the
per-protocol handlers key.
2026-03-01 22:14:58 +08:00
Amos Bird b503accc7f Remove NetlinkMetricsProvider, use procfs exclusively for taskstats
Netlink-based metric collection is problematic in containerized environments
(Docker, LXC, Kubernetes) where it can hang indefinitely. Benchmarks show
procfs has better tail latency and lower total CPU overhead under contention.
Since all production deployments already use the procfs path, remove netlink
entirely rather than adding a setting to disable it.
2026-02-28 11:32:25 +08:00
Alexey MilovidovandClaude Opus 4.6 354cfbae6c Call OpenSSLInitializer::cleanup before safeExit to fix LeakSanitizer false positives
When the server takes the forced shutdown path via `safeExit` → `_exit`,
static destructors and atexit handlers are bypassed, so
`OpenSSLInitializer::cleanup` / `OPENSSL_cleanup` never runs.
ASan intercepts `_exit` and runs LSan, which reports OpenSSL's global
cached state (EVP method cache, legacy provider context) as leaked memory.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97652&sha=c9d73d1a85abfa220c6ddad38d81e7acb72be2e9&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-28 04:03:34 +01:00
Anton Popov ccc73b9a44 Merge remote-tracking branch 'upstream/master' into HEAD 2026-02-27 10:56:35 +00:00
RinChanNOWWW d36d5bb840 Support auxiliary keeper for DatabaseReplicated.
Mark getObjectStorage as const.

Add docs and tests.

Fix.

Fix drop replica.

Fix getQueryStatus.

Fix test.

Fix zookeeper usage.

Fix codes review.

Split the tests.
2026-02-27 10:37:23 +08:00
Anton Popov 8f1b9a5f6c Merge remote-tracking branch 'upstream/master' into HEAD 2026-02-26 12:38:20 +00:00
Alexey MilovidovandGitHub e8654c51eb Revert "Improve help output for ClickHouse applications" 2026-02-26 07:51:17 +01:00
Antonio AndelicandGitHub 4c91652224 Merge pull request #97945 from ClickHouse/jemalloc-profiler-sampling-rate
Add `jemalloc_profiler_sampling_rate` server setting
2026-02-25 17:09:38 +00:00
Antonio AndelicandClaude Opus 4.6 a0564970cf Fix missing extern declarations and add jemalloc.prof.lg_sample async metric
- Add missing `extern` for `jemalloc_profiler_sampling_rate` in
  `Keeper.cpp`, `LocalServer.cpp`, and `Server.cpp`
- Pass `jemalloc_profiler_sampling_rate` as 5th argument to
  `Jemalloc::setup` in `Keeper.cpp` and `LocalServer.cpp`
- Expose `prof.lg_sample` via `system.asynchronous_metrics` as
  `jemalloc.prof.lg_sample`
- Add integration test `test_jemalloc_profiler_sampling_rate`

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-25 14:31:07 +01:00
Antonio AndelicandClaude Opus 4.6 7a37ad7c29 Add jemalloc_profiler_sampling_rate server setting
Allow controlling jemalloc's `lg_prof_sample` via a server setting,
which determines the average interval between allocation samples.
The default value of 19 (512 KiB) matches jemalloc's built-in default.
When a non-default value is configured, `Jemalloc::setup` calls
`prof.reset` to apply the new sampling rate.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-25 12:10:25 +01:00
5c5ceac759 Replace heavy StorageReplicatedMergeTree.h include with targeted MergeTreeBackgroundExecutor.h in Server.cpp
`Server.cpp` included `StorageReplicatedMergeTree.h` but never used the
`StorageReplicatedMergeTree` class directly. The only dependency was on
`MergeTreeBackgroundExecutor` for thread pool management (accessed via
`Context::getMergeMutateExecutor` etc.).

`StorageReplicatedMergeTree.h` is an extremely heavy header that
transitively pulls in `MergeTreeData.h`, `SortCursor.h` (with expensive
`std::variant` instantiations for sorting queues), `MergeTask.h`,
`MergeFromLogEntryTask.h`, `TextIndexUtils.h`, and `DataPartsExchange.h`.
The time trace showed 3.9s just for parsing `StorageReplicatedMergeTree.h`
plus ~4.3s of template instantiations from `SortCursor.h` variant types.

Replacing it with the targeted `MergeTreeBackgroundExecutor.h` reduces
`Server.cpp.o` compile time from 34.8s to 28.1s (-19%). Since `Server.cpp`
is on the critical path (last .o file to finish before linking), this
directly reduces wall time.

Build time: 5m6.0s (was 5m16.7s, -10.7s / -3.4%)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-24 18:20:20 +01:00
Anton Popov 271ac98247 add cache for single tokens 2026-02-20 20:38:43 +01:00
Anton Popov fb7135602c optimize reading from the text index dictionary 2026-02-20 19:29:25 +01:00
Raúl MarínandGitHub 2331269ca4 Merge pull request #96810 from c-end/dns_address_filter
Apply filtering by IP address family even if DNS cache is disabled
2026-02-20 10:32:04 +00:00
Nikolai KochetovandGitHub 443bf8095c Merge pull request #95003 from ClickHouse/check-memory-limit-earlier
Check total memory limit overflow earlier.
2026-02-19 15:17:04 +00:00
Raúl MarínandGitHub c88d51353b Merge branch 'master' into dns_address_filter 2026-02-19 14:55:05 +01:00
Nikolai KochetovandGitHub ad9d023146 Update Server.cpp 2026-02-17 18:57:52 +01:00
Robert Schulze 24a90cdc06 Fix build 2026-02-16 21:36:59 +00:00
Alexey MilovidovandGitHub 44408616c7 Merge pull request #80295 from ClickHouse/respect-command-line-overrides-while-reloading-config
Respect command-line overrides when reloading configuration
2026-02-16 20:43:39 +01:00
Christian Endres b36fa5f28e Apply filtering by IP address family even if DNS cache is disabled 2026-02-13 11:50:19 +00:00
Alexey Milovidov 223e53c76d Revert "Merge pull request #89750 from grantholly-clickhouse/parquet_footer_cache"
This reverts commit 5243ef786e, reversing
changes made to 6e3a5ad955.
2026-02-13 01:03:02 +01:00
Nikolai KochetovandGitHub 951d955d71 Merge branch 'master' into check-memory-limit-earlier 2026-02-11 19:25:04 +01:00
Miсhael StetsyukandGitHub 03df599806 Merge pull request #96524 from ClickHouse/hot-reload-core_dumps
Make core dump size limit configuration setting hot-reloadable
2026-02-10 19:03:06 +00:00
Nikolai Kochetov f17a6e12a7 Merge branch 'master' into check-memory-limit-earlier 2026-02-10 19:03:53 +01:00
Ilya YatsishinandGitHub 2da7b40d7a Revert "Fix relative config paths resolving against wrong directory after chdir" 2026-02-10 13:16:15 +01:00
Michael Stetsyuk e1b6c70a8a make core dump size limit configuration setting hot reloadable 2026-02-10 11:07:51 +00:00
divanik 5c33f119b5 Merge branch 'master' of github.com:ClickHouse/ClickHouse into parquet_footer_cache 2026-02-09 13:28:20 +01:00
Alexey MilovidovandClaude Opus 4.6 cbfa7d9f5a Fix test_server_no_logging by restoring log level before accepting connections
The config reload callback (`ConfigReloader`) fires during construction with
`initial_loading=true`. After the change to use `updateLevels(config(), ...)`
instead of `updateLevels(*config, ...)`, the callback reads `logger.level`
from the layered configuration, where the writable `MapConfiguration` at
`PRIO_APPLICATION` still holds the startup level override ("trace"). This
keeps the log level at "trace" until the explicit restoration after
`server.start()`, creating a window where HTTP requests get logged at
trace level.

Move the startup level restoration to before `server.start()` so that
no requests are ever served with the elevated startup log level.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=80295&sha=c7c2c8bd852fc40cf3640ee5810c7976dcfda96c&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%201%2F6%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-08 12:08:50 +01:00
Alexey MilovidovandClaude Opus 4.6 e49958ad29 Use replace for ZK includes config reload; add integration test
Fix the ZK includes reload path in `Server.cpp` to use
`config().replace` instead of `removeConfiguration`/`add`/`setConfig`,
consistent with the reload callback. This ensures command-line overrides
are preserved when ZK includes are loaded.

Add integration test `test_config_not_overriding_args` that verifies
command-line arguments are not overridden by config file values
(including when ZK includes are used). Based on the test from #71452.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-08 07:21:07 +01:00
Alexey MilovidovandClaude Opus 4.6 9c9af9f585 Rename replaceByLabel to replace
Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-08 00:14:02 +01:00
Alexey MilovidovandClaude Opus 4.6 0e1b9c066d Fix use-after-free in replaceByLabel by using shared ownership
The `replaceByLabel` calls in `Server.cpp` and `Keeper.cpp` passed
`shared = false`, which means the `AutoPtr` inside `LayeredConfiguration`
took the raw pointer without incrementing the reference count. But the
caller's `loaded_config` `AutoPtr` also holds a reference. When the
callback's `loaded_config` goes out of scope, its destructor decrements
the reference count, potentially freeing the object while the
`LayeredConfiguration` still holds a pointer to it.

Passing `shared = true` makes the `AutoPtr` constructor call `duplicate`,
properly incrementing the reference count so the `LayeredConfiguration`
has its own counted reference.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-07 23:48:47 +01:00
Grant Holly d4179cbd85 merging in upstream master 2026-02-07 13:16:29 -08:00
Alexey MilovidovandClaude Opus 4.6 aa7578d2d0 Fix relative config paths resolving against wrong directory after chdir
`BaseDaemon::initialize` performs up to 3 `chdir` calls during daemon
startup (to application path, log path, and cores directory). After
`initialize` returns, `Server::main` reads path settings from config.
If those paths are relative, they resolve against the cores directory
instead of the original startup directory.

Fix by capturing the original working directory at the start of
`BaseDaemon::initialize` and using it to resolve the main `path`
setting to absolute. All secondary path settings (like `user_files_path`,
`tmp_path`, `format_schema_path`, etc.) are resolved relative to the
now-absolute main `path`.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-07 06:09:00 +01:00
Alexey MilovidovandClaude Opus 4.6 8774f046fc Add atomic replaceByLabel to LayeredConfiguration for thread-safe config reload
The config reload callback in `Server.cpp` and `Keeper.cpp` was doing
`find` + `removeConfiguration` + `add` on the shared `LayeredConfiguration`
from the `ConfigReloader` thread. This is not thread-safe because concurrent
readers (calling `getString`, etc.) iterate the same internal list without
synchronization against structural modifications.

`AbstractConfiguration` already has `mutable Poco::Mutex _mutex` that all
public read methods lock. The new `replaceByLabel` method locks the same
`_mutex` and atomically swaps the config pointer within the matching list
node — no list insert/erase needed for the common case, guaranteeing mutual
exclusion with concurrent readers.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-07 00:43:46 +01:00
Alexey MilovidovandClaude Opus 4.6 63c334301e Fix the order of config replacement in Server.cpp
The previous order (add new, find, remove) was incorrect because
`LayeredConfiguration::add` inserts at the same priority position
before existing entries, and `find` returns the first match.
This means the newly added config was found and removed instead
of the old one.

Changed to match the correct order used in Keeper.cpp:
find old, remove old, add new.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-07 00:19:01 +01:00
Alexey Milovidov f920b73f93 Merge branch 'master' into respect-command-line-overrides-while-reloading-config
# Conflicts:
#	programs/keeper/Keeper.cpp
#	programs/server/Server.cpp
2026-02-07 00:15:21 +01:00
Alexey MilovidovandGitHub 1bc8e2eca6 Merge pull request #95919 from garrettthomaskth/startup-and-shutdown-console-log-level
add startup and shutdown console log level
2026-02-06 22:37:29 +01:00
Alexey Milovidov a41f649e4d Merge branch 'master' into clickhouse-help 2026-02-05 20:27:00 +01:00
divanik 6571c48297 Merge branch 'master' of github.com:ClickHouse/ClickHouse into parquet_footer_cache 2026-02-05 17:32:40 +01:00
Antonio Andelic 4d63898331 Fix global profiler values 2026-02-05 12:59:25 +01:00
Alexey MilovidovandClaude Opus 4.5 62ccfbd3aa Improve help output for ClickHouse applications
This commit improves the help output for all ClickHouse applications:

- Add `clickhouse help` command that lists all available subcommands
- Return exit code 0 for all help messages (previously some returned 1)
- Output help messages to stdout instead of stderr
- Use "clickhouse <cmd>" format instead of argv[0] in help messages
- Add dynamic `app_name` detection for `clickhouse client` and `clickhouse local`
  to show correct invocation name based on how the binary was called
- Add `--no-sudo` option for `clickhouse start` and `clickhouse restart`
  for environments without sudo (e.g., Docker containers)
- Add detailed help headers and footers for client and local with usage examples

Closes #58244

Co-Authored-By: Claude Opus 4.5 <[email protected]>
2026-02-05 07:12:44 +01:00
garrettthomas 5af5872d23 fix instances of old name 2026-02-03 21:52:43 -08:00
garrettthomas 7a5e155c69 fix instances of old name 2026-02-03 16:41:07 -08:00
Garrett ThomasandGitHub 2e0fb48848 Merge branch 'master' into startup-and-shutdown-console-log-level 2026-02-03 15:47:20 -08:00
garrettthomas e128f6a237 fix names 2026-02-03 15:44:05 -08:00
garrettthomas 1c3ed8fbd5 add startup and shutdown console log level 2026-02-03 15:31:53 -08:00
Grant Holly 45e8756dc9 Merge branch 'master' into parquet_footer_cache 2026-02-02 14:44:57 -08:00