Commit Graph
1916 Commits
Author SHA1 Message Date
Sema Checherinda d452c036cf fix: validate insert_deduplication_version before applying a config reload
The runtime reload guard validated after `config().replace`, so a rejected
`SYSTEM RELOAD CONFIG` had already swapped in the new configuration:
`system.server_settings` would then report an unsupported legacy value even
though the reload failed, and `ConfigReloader` has no rollback hook. Validate
the incoming configuration before `config().replace`, so a rejected reload
leaves the previous valid config untouched. The integration test now asserts
`system.server_settings` still reports `new_unified_hash` after the rejected
reload.
2026-06-25 16:08:47 +02:00
Sema Checherinda 0b7abc5660 fix: apply the insert_deduplication_version guard to every server-settings load
The fail-closed guard validated only the first loadSettingsFromConfig, so a legacy
`insert_deduplication_version` arriving via a ZooKeeper config include (reloaded during startup) or a
runtime `SYSTEM RELOAD CONFIG` could slip past it, leaving the server running unified-only while the
setting still named a legacy mode. Factor the check into a helper and run it after every
server-settings load: the initial load, the ZooKeeper-include reload, and the config reloader.
Throwing in the reloader rejects the offending reload and keeps the previous valid config.

Extend test_insert_deduplication_version_guard with a reload case asserting that SYSTEM RELOAD CONFIG
to a legacy value is rejected and the server stays up on the valid value.
2026-06-25 12:03:26 +02:00
Sema Checherinda 0ee942d455 feat: fail closed on a legacy insert_deduplication_version at startup
This build writes only the unified insert deduplication hash. An operator left
on a legacy `insert_deduplication_version` (`old_separate_hashes` or
`compatible_double_hashes`) would otherwise silently lose the mixed-version
deduplication contract during a rolling upgrade. Validate the server setting at
startup and refuse to start, with a migration message, unless it is
`new_unified_hash`.

The setting is therefore no longer obsolete: restore it as a normal server
setting, drop it from the obsolete-settings reference, and stop the
`casa_del_dolor` fuzzer from assigning it a value that would abort startup.

Rework `test_parallel_replicas_protocol` to populate the shared table from a
single replica and propagate by replication; the new build no longer shares an
insert deduplication hash with the old replicas, so inserting identical data
from every replica can no longer rely on cross-version deduplication. Add an
integration test asserting the guard fails closed.
2026-06-24 16:15:01 +02:00
Alexey MilovidovandGitHub 969978989c Merge pull request #101143 from ClickHouse/local-server-system-listen
Support SYSTEM START/STOP LISTEN in clickhouse-local
2026-06-22 20:30:22 +02:00
murphy-4oandGitHub c46081e195 Merge pull request #105401 from murphy-4o/uk-pr-3-bitmap-store
UNIQUE KEY: Bitmap sidecar store, part APIs, and cache wiring (3/N)
2026-06-22 12:54:33 +00:00
Sergei TrifonovandGitHub 994d948d93 Merge pull request #102928 from seva-potapov/concurrencycontrol-lazy-allocation
Fix SELECT slowdown caused by simple INSERTs holding unused CPU slots
2026-06-22 10:28:21 +00:00
murphy-4o ec8bf665b2 Merge branch 'master' into uk-pr-3-bitmap-store
# Conflicts:
#	src/Storages/MergeTree/UniqueKey/DeleteBitmap.cpp
2026-06-22 12:59:31 +08:00
Alexey MilovidovandClaude Opus 4.8 289039e086 Fix build after merge: restore NETWORK_ERROR error code in Server.cpp
The merge with master brought in the multistage distributed queries
feature, whose `ExchangeServer` startup code in `Server.cpp` throws
`Exception(ErrorCodes::NETWORK_ERROR, ...)`. This branch had removed the
`extern const int NETWORK_ERROR;` declaration from `Server.cpp` because
its only previous use (in `Server::createServer`) was extracted into
`src/Server/createServer.cpp`. Restore the declaration so the new use
compiles.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-17 15:03:03 +00:00
Alexey Milovidov a88469d95d Merge remote-tracking branch 'origin/master' into local-server-system-listen 2026-06-17 15:03:02 +00:00
Miсhael StetsyukandGitHub e78aeb970e Merge pull request #107291 from ClickHouse/static-thread-pool-shutdownall
Fix stuck shutdown in server and local and join all global pool threads in all binaries
2026-06-17 13:44:41 +00:00
Antonio AndelicandGitHub 47f6c3116b Merge pull request #106822 from linjiayu1025-collab/keeper_server_secure
Fix keeper_server.http_control.secure_port serves plaintext HTTP instead of HTTPS
2026-06-17 12:14:22 +00:00
Den Kalantaevskii 2fb02911ff private sync 2026-06-16 15:51:30 +00:00
linjiayuandhaozelong 5f759fbcbe Fix keeper_server.http_control.secure_port serves plaintext HTTP instead of HTTPS 2026-06-16 13:50:33 +08:00
Alexander GololobovandGitHub 239073ef8e Merge pull request #107146 from ClickHouse/revert-107122-revert-106020-multistage-distributed
Revert "Revert "Multistage distributed queries" (#106020) — fixes ASan heap corruption on master"
2026-06-15 14:54:48 +00:00
murphy-4oandClaude Opus 4.7 77183ded71 UNIQUE KEY: bitmap sidecar store, part APIs, cache wiring (3/N)
Third slice of the UNIQUE KEY stack. Lands the per-part delete-bitmap
storage layer on top of PR-2's DeleteBitmap + DeleteBitmapFileOps
primitives, aligned with the CSN-based transaction model documented
in design/txn/transaction_consistency.md.

Why a separate bitmap store. UNIQUE KEY needs to mark logically-deleted
rows without rewriting the part. Each commit publishes one cumulative
bitmap per touched part, tagged by a monotonic per-partition version.
Readers pin a snapshot version and consult the bitmap with
`max version ≤ snapshot` for each part — that's the snapshot-isolation
primitive for UK reads, INSERT-time probe, and merge-time row
resolution. This PR delivers the storage and read/write API for that
bitmap; the transaction-control plane (version allocation, partition
mutex, query snapshot, manifest, recovery) lands in later PRs.

What's in this PR:
- MergeTreeBitmapStore — one per table. Atomic install at a version
  (strictly monotonic; throws LOGICAL_ERROR otherwise), snapshot-pinned
  read returning (shared_ptr<const DeleteBitmap>, chosen_version),
  (V_b, V_next)-rule GC, and dropPart for parts leaving the active
  set. Keeps an in-memory version index per part (rebuilt from disk on
  first access) so the hot read path is map lookup + binary search,
  not a syscall.
- DeleteBitmapCache — process-wide cache for deserialized bitmaps,
  keyed by stable part identity + version. Configurable via
  unique_key_bitmap_cache_* settings, wired through Context startup/
  reload, observable via DeleteBitmapCache* metrics and
  UniqueKeyBitmap* events.
- IMergeTreeDataPart — cache-identity accessor for callers building
  cache keys; delete_bitmap_<csn>.rbm enumeration in
  getFileNamesWithoutChecksums so BACKUP and replication-fetch carry
  bitmap sidecars.

Why the API is shaped this way:
- Bitmaps are immutable by version. readBitmap returns
  shared_ptr<const DeleteBitmap> so a writer building a new version
  must copy, never mutate the cached older snapshot.
- The store is concrete (no IUniqueKeyBitmapStore interface). Future
  SharedMergeTree variant runs a fundamentally different protocol
  (Keeper-coordinated S3 with (bn, uuid) refs); a shared base wouldn't
  fit at this layer.
- Integration with active reads/writes lands in later slices (PR 4
  read filter, PR 5 DELETE, PR 13 INSERT/UPSERT commit, PR 14a merge
  reconcile).

Tests: 39 / 39 PASS in DeleteBitmap*:*BitmapFileOps*:*MergeTreeBitmapStore*
filter:
- 20 DeleteBitmapTest (primitive)
- 1 DeleteBitmapCacheTest (cache wrapper)
- 11 DeleteBitmapFileOpsTest (file I/O)
- 7 MergeTreeBitmapStoreTest: read empty / max-≤-snapshot pick / cache
  reuse / GC removal / GC committed-filter / dropPart / corrupt-file
  surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-06-15 21:32:04 +08:00
Miсhael StetsyukandGitHub 551dbd1db2 Merge pull request #107187 from ClickHouse/revert-106727-fix-startup-scripts-reload
Do not run startup scripts on config reload
2026-06-15 10:02:06 +00:00
Alexander Gololobov f06576dbff Merge remote-tracking branch 'origin/master' into revert-107122-revert-106020-multistage-distributed
# Conflicts:
#	src/Processors/Transforms/ScatterByPartitionTransform.cpp
2026-06-14 23:01:11 +02:00
Alexey Milovidov f14ef43632 Merge remote-tracking branch 'origin/master' into local-server-system-listen 2026-06-14 16:50:49 +00:00
Alexey MilovidovandGitHub 40359661e7 Merge pull request #101447 from tuanpach/fix-workload-storage-lifetime-race
Fix use-after-free of workload storage mutex during server shutdown
2026-06-13 20:40:44 +00:00
Alexey Milovidov 1b780f54bc Merge remote-tracking branch 'origin/master' into local-server-system-listen 2026-06-13 02:30:26 +00:00
Alexey MilovidovandGitHub 436c6f159d Merge pull request #104964 from ClickHouse/memory-worker-dynamic-limit
Dynamically adjust memory limit based on system free/cached memory
2026-06-12 19:39:27 +00:00
Alexander GololobovandClaude Fable 5 cbf4b26470 Shrink idle thread pools of the distributed query infrastructure
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-12 10:48:35 +02:00
Alexey Milovidov f3d3f575d1 Merge remote-tracking branch 'origin/master' into local-server-system-listen 2026-06-12 00:41:26 +00:00
Michael Stetsyuk 3a9c7df8d2 Join threads from global thread pool before exiting from main 2026-06-11 21:45:31 +00:00
Alexey MilovidovandClaude Fable 5 272db20fa0 Add memory_worker_dynamic_hard_limit setting to opt out of the runtime limit adjustment
Address review: a positive max_server_memory_usage_to_ram_ratio used to
opt the server into runtime hard-limit shrinking with no way to keep the
previous static cap, while setting the ratio to 0 removed the cap
entirely. The new memory_worker_dynamic_hard_limit server setting
(enabled by default) gates only the runtime adjustment: when disabled,
max_server_memory_usage_to_ram_ratio caps the hard memory limit
statically at startup and on configuration reload, exactly as in
previous versions.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-11 16:17:04 +00:00
Azat KhuzhinandGitHub 32cedf25cc Merge pull request #101942 from fastio/feature-oom-canary
Add OOM canary: a sacrificial child process to protect the server from the OOM killer
2026-06-11 12:17:44 +00:00
Raúl MarínandGitHub 4190813eef Merge pull request #107033 from Algunenano/darwin-thread-stack-size
Use an 8 MiB thread stack on Darwin to avoid stack overflow in JIT codegen
2026-06-11 10:21:16 +00:00
Miсhael StetsyukandGitHub 5b08f689b0 Revert "Fix logical error in startup scripts in SYSTEM RELOAD CONFIG" 2026-06-11 11:01:42 +01:00
Alexander GololobovandGitHub 41edd03279 Revert "Revert "Multistage distributed queries" (#106020) — fixes ASan heap corruption on master" 2026-06-11 06:09:43 +02:00
Alexey Milovidov c8328abbd9 Revert "Merge pull request #106020 from ClickHouse/multistage_distributed_queries"
This reverts commit c3131f3265, reversing
changes made to 4f3fe68b90.
2026-06-11 01:27:26 +00:00
Alexey Milovidov 1fa92f9aec Revert "Merge pull request #106978 from ClickHouse/distributed-plan-shrink-idle-thread-pools"
This reverts commit 4f2c87963e, reversing
changes made to 56d78b5c22.
2026-06-11 01:27:11 +00:00
Alexander GololobovandGitHub e9e12b9017 Merge pull request #106978 from ClickHouse/distributed-plan-shrink-idle-thread-pools
Shrink idle thread pools of the distributed query infrastructure
2026-06-10 19:04:48 +00:00
Raúl Marín 103d070e24 Use an 8 MiB thread stack on Darwin to avoid stack overflow in JIT codegen 2026-06-10 18:29:42 +02:00
Alexander GololobovandClaude Fable 5 f2a5248652 Reject stateless_worker_server.max_threads=0
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-10 15:55:09 +02:00
Alexander GololobovandClaude Fable 5 fccf8073bb Shrink idle thread pools of the distributed query infrastructure
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-10 15:35:21 +02:00
Miсhael StetsyukandGitHub 4e2a34fe26 Merge pull request #106727 from ClickHouse/fix-startup-scripts-reload
Fix logical error in startup scripts in SYSTEM RELOAD CONFIG
2026-06-10 12:39:10 +00:00
Michael Stetsyuk 80bf58fa66 do not rename os thread in loadStartupScripts 2026-06-09 18:25:56 +00:00
Michael Stetsyuk 607c541231 Fix logical error in startup scripts in SYSTEM RELOAD CONFIG 2026-06-08 14:58:01 +00:00
Alexey Milovidov 31678faee7 Merge remote-tracking branch 'origin/master' into local-server-system-listen 2026-06-07 08:34:08 +00:00
Alexey Milovidov 2d67c3c0c5 Merge remote-tracking branch 'origin/master' into memory-worker-dynamic-limit 2026-06-07 04:44:12 +00:00
Alexey MilovidovandClaude Opus 4.8 6e5d95a75c Fix shutdown-concurrent lifetime race in lazy resource-manager init
The previous fix protected `PipelineExecutor::allocateCPU` and the
query-execution callers, but the lazy initialization of the resource
manager still observed the same shutdown race.

`Context::getWorkloadClassifier` initializes the resource manager lazily
through `getResourceManager`, which calls `createResourceManager`. That
passed `getWorkloadEntityStorage()` (a raw reference whose owning
`shared_ptr` temporary is destroyed at the end of the full expression),
so no owner was held across `WorkloadResourceManager`'s constructor while
it runs `getAllEntitiesAndSubscribe`. If this first lazy init overlaps
shutdown's reset of `workload_entity_storage`, the storage can be
destroyed while the constructor is still using it — the same
`recursive_mutex` use-after-free this PR set out to fix.

Make `WorkloadResourceManager` take and retain a
`shared_ptr<IWorkloadEntityStorage>`, and have `createResourceManager`
pass `getWorkloadEntityStoragePtr`. The storage is only touched in the
constructor, so holding the owner for the manager's lifetime is more than
sufficient.

Also remove the now-unused reference accessor
`Context::getWorkloadEntityStorage` (the last caller in `Server.cpp`'s
startup `loadEntities` is migrated to `getWorkloadEntityStoragePtr`), so
the shutdown-unsafe accessor can no longer be reintroduced.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-06 11:53:22 +00:00
Alexander Gololobov 1740db5ef3 Merge branch 'master' of github.com:ClickHouse/ClickHouse into multistage_distributed_queries 2026-06-06 09:35:45 +02:00
Miсhael StetsyukandGitHub eb3f7f5fe8 Merge pull request #105617 from ClickHouse/system-keeper-changelogs
Add system.keeper_changelogs table
2026-06-05 11:10:40 +00:00
Alexey Milovidov eaf13ba145 Merge remote-tracking branch 'origin/master' into local-server-system-listen 2026-06-05 06:29:04 +00:00
Alexey Milovidov d7ded9b04d Merge remote-tracking branch 'origin/master' into memory-worker-dynamic-limit 2026-06-05 02:18:09 +00:00
Alexander GololobovandClaude Opus 4.8 482675907a Require explicit listen host to enable the streaming exchange server
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-04 17:01:51 +02:00
Michael Stetsyuk 3cb79ab57c Gate system.keeper_changelogs behind USE_NURAFT
Fixes FreeBSD build: tryGetKeeperDispatcher is only declared when
USE_NURAFT is set, and the storage's transitive includes pull in NuRaft
headers.
2026-06-04 13:28:35 +00:00
Michael StetsyukandClaude Opus 4.7 c44734622f Add system.keeper_changelogs table
New keeper-only system table with one row per on-disk Raft log file
(changelog_<from>_<to>.bin[.zstd]) tracked by the in-process Keeper.
Mirrors the plumbing of system.keeper_snapshots.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-06-04 13:28:35 +00:00
Alexander GololobovandClaude Opus 4.8 6ee7ca2b55 Remove the configured stateless worker endpoint name on shutdown
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-04 09:43:22 +02:00
murphy-4oandGitHub 31874f78ed Merge branch 'master' into uk-pr-7-dense-index-cache 2026-06-04 12:13:20 +08:00