Commit Graph
198 Commits
Author SHA1 Message Date
Antonio AndelicandClaude Opus 4.6 ff77da68c9 Use signalKeeperDispatcherShutdown wrapper in standalone Keeper
Avoid code duplication by calling the same `Context::signalKeeperDispatcherShutdown`
method that `Server.cpp` uses, instead of inlining the dispatcher lookup.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-03 15:26:14 +01:00
Alexey MilovidovandClaude Opus 4.6 8c8cbe6ffc Fix Keeper TCP handler preventing graceful server shutdown
During shutdown, `KeeperTCPHandler` connections run an infinite loop
with no shutdown detection. When the server stops the Keeper TCP
listening socket, existing handler threads keep processing heartbeats
indefinitely. `KeeperDispatcher::shutdown` (which sets the shutdown
flag) is only called after waiting for connections to close, creating
a circular dependency that blocks shutdown until the external timeout
kills the server.

Add a `shutting_down` flag to `KeeperDispatcher` that is set before
waiting for connections. `KeeperTCPHandler` checks this flag after
each `poll` return and exits cleanly when set.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98447&sha=79d30b439bc793fc9aa276b28aec105750847880&name_0=PR&name_1=Stateless%20tests%20%28arm_asan%2C%20azure%2C%20parallel%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-02 18:46:50 +01: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
Alexey MilovidovandGitHub cc6a29736e Revert "Call OpenSSL cleanup before safeExit to fix LeakSanitizer false positives" 2026-03-01 00:21:39 +01:00
Alexey MilovidovandClaude Opus 4.6 4cfb864414 Call OpenSSL cleanup before safeExit in Keeper too
The same `safeExit` pattern exists in `programs/keeper/Keeper.cpp`.
Apply the same `OpenSSLInitializer::cleanup` call to avoid
LeakSanitizer false positives in Keeper as well.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-28 16:48:48 +01:00
Alexey MilovidovandGitHub e8654c51eb Revert "Improve help output for ClickHouse applications" 2026-02-26 07:51:17 +01: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
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
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 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 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
Antonio Andelic cb99079a8b Merge branch 'master' into less-shitty-memory-worker2 2026-01-26 16:42:21 +01:00
Antonio Andelic 90f604248d Cleanup 2026-01-26 11:12:47 +01:00
Antonio Andelic 773a2bfeed Merge branch 'master' into enable-implicit-int-float-conversion 2026-01-26 10:25:31 +01:00
Antonio Andelic 5d7d52d826 Change dirty_decay_ms 2026-01-23 13:24:52 +01:00
Antonio Andelic f8e078c25e Review fixes 2026-01-23 12:58:28 +01:00
Antonio Andelic d718baab40 Run jemalloc dirty pages purging in a different thread 2026-01-23 11:28:39 +01:00
Antonio Andelic dc3d47d689 Enable implicit-int-float-conversion check 2026-01-20 09:35:57 +01:00
Antonio Andelic 36c4767a2a Merge branch 'master' into implicit-int-conversion 2026-01-12 09:31:50 +01:00
Raúl MarínandGitHub 12ef4d25d0 Merge pull request #93679 from Algunenano/build_clean
Cleanup some build flags
2026-01-09 15:06:32 +00:00
Raúl Marín 5a5673539d Missing files 2026-01-08 17:14:36 +01:00
Antonio Andelic 8884aa496a Merge branch 'master' into implicit-int-conversion 2026-01-08 13:32:51 +01:00
Eduard KaracharovandAzat Khuzhin dfddf71f25 MemoryWorker: force purging dirty pages on threshold exceeded
Make memory worker to be able to preventilvely purge jemalloc arenas,
if the size of dirty pages exceeds pre-configured threshold ratio
(relatively to `max_server_memory_usage`), even if the process memory
is below memory tracker limit.

Co-authored-by: Azat Khuzhin <[email protected]>
2026-01-08 08:24:09 +02:00
Antonio Andelic 1b27ae2c7b Merge branch 'master' into wide-integer-explicit-cast 2026-01-07 16:32:44 +01:00
Antonio Andelic 340be5a496 Enable implicit-int-conversion check 2026-01-07 16:30:57 +01:00
pufit e8f282d62a Merge branch 'master' into ch-keeper-http-api-v1
# Conflicts:
#	programs/keeper-client/KeeperClient.cpp
#	programs/keeper-client/KeeperClient.h
#	programs/server/Server.cpp
#	src/Server/HTTPRequestHandlerFactoryMain.cpp
2025-12-29 19:46:51 -05:00
copilot-swe-agent[bot]andtavplubix 1dc076dc28 Fix trailing whitespaces in modified files
Co-authored-by: tavplubix <[email protected]>
2025-09-20 16:21:59 +00:00
copilot-swe-agent[bot]andtavplubix 53e80cd99d Add configurable TCP_NODELAY support to TCPServerParams and Keeper
Co-authored-by: tavplubix <[email protected]>
2025-09-20 13:55:10 +00:00
Azat Khuzhin a4da40949f Remove API for ZooKeeper client with WatchCallback completelly (leave only Ptr part) 2025-09-09 13:50:26 +02:00
Azat Khuzhin 04d64a7ca1 Fix deduplication of watches in ZooKeeper client by EventPtr
While adding a chassert, I also discovered an issue with EventPtr: it
was never deduplicated, since it was always wrapped into a callback.
This has now been fixed as well.
2025-09-08 12:01:08 +02:00
Antonio Andelic 292f6dfe1c Fix build 2025-09-02 13:07:28 +02:00
Antonio Andelic 26bb3e6274 Refactor and improve queries 2025-08-14 11:34:41 +02:00
Alexey Milovidov 8c96a48551 Remove GWP-ASan 2025-07-20 02:52:28 +02:00
Raúl Marín d6ac63c8d2 Style: Forbid the use of quotes for includes (partial) 2025-06-24 13:20:10 +02:00
Alexey Milovidov 8f2d66e71b Respect command-line overrides when reloading configuration 2025-05-16 04:04:16 +02:00
pufit 7ec601dc54 Merge branch 'master' into ch-keeper-http-api-v1 2025-04-20 21:46:09 -04:00
Konstantin Bogdanov 678acbafdc Fix OpenSSL early init 2025-04-10 21:33:00 +02:00
Azat Khuzhin 9da0377f02 Move FiberStack implementation out from header 2025-03-30 20:49:05 +02:00
pufit 9cf7c4ced2 Merge branch 'master' into ch-keeper-http-api-v1
# Conflicts:
#	src/Server/KeeperReadinessHandler.cpp
2025-03-24 11:45:25 -04:00
Raúl Marín df9ebc8c45 Make a few example binaries smaller 2025-03-14 18:22:03 +01:00
Bharat Nallan Chakravarthy 9a5e167756 try to use PreformattedMessage 2025-03-05 16:06:11 -08:00
Bharat Nallan Chakravarthy 082a6d59fd Merge branch 'master' into ncb/improve-system-warnings 2025-03-05 07:21:49 -08:00
Nikita MikhaylovandGitHub b08d050a56 Revert "Revert "Userspace page cache v2"" 2025-03-04 16:39:20 +01:00
Alexander TokmakovandGitHub af555e2c24 Revert "Userspace page cache v2" 2025-03-04 16:32:41 +01:00
Bharat Nallan Chakravarthy f564bf85f6 support message_format_string for warnings 2025-02-17 23:09:59 -06:00
Michael Kolupaev 3df639ab57 Merge remote-tracking branch 'origin/master' into npc 2025-02-14 22:32:52 +00:00
Antonio Andelic b6b6556b09 Correct MemoryTracker with MemoryWorker 2025-02-07 13:48:40 +01:00
Antonio Andelic 436b84a628 Add includes 2025-02-05 16:58:48 +01:00