2014 Commits
Author SHA1 Message Date
zeekayandHanzo Dev a7786758f8 Restore upstream citations broken by a global rename
A prior ClickHouse to Datastore rename rewrote `github.com/ClickHouse/ClickHouse`
to `github.com/Datastore/Datastore`, a repository that does not exist. That
turned 162 references across 131 files into dead links, and turned captured
stack traces and historical changelogs into false statements.

A citation of upstream is a fact, not branding. Product surfaces keep the Hanzo
Datastore name; references to the upstream project point at the upstream project.
Also untracks `.claude/`, agent scratch that was never meant to be committed.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-26 19:24:23 -07:00
zeekay 9a90943b8f merge: ClickHouse 26.7.1.1315-stable into datastore — preserve debrand
13,838 upstream commits, forward from the 26.6.1.1 fork point. 129 conflicts:
37 resolved mechanically (take upstream's file, re-apply the brand sweep) and
92 by hand where our fork and upstream had both changed the same code.

The rule throughout: upstream owns the engine, we own the naming and a small set
of deliberate deviations. Never resolve by discarding an upstream change — a
dropped rename or a missed new parameter becomes a compile error a thousand
files away.

Deviations verified intact after the merge:
  ENABLE_XRAY still defaults OFF        (CMakeLists.txt:105)
  X-Datastore-User read by the server   (authenticateUserByHTTP.cpp)
  X-ClickHouse-* in src/                0
  hanzo/research                        present
  system.*_log retention bound          present
  ArrowFlight rip                       held against upstream re-adding it

Two things worth naming, because neither shows up as a conflict:

  src/CMakeLists.txt gained an UNGUARDED
  `add_object_library(datastore_storages_arrowflight Storages/ArrowFlight)` from
  upstream, for a directory our gRPC rip deleted. It sat outside every conflict
  hunk, so a resolver reading only the markers would sail straight past it into
  a CMake configure error. Removed; the Server/ArrowFlight sibling at line 474
  stays because it is inside `if (TARGET ch_contrib::arrow_flight)`.

  The brand sweep had rewritten github.com/ClickHouse/ClickHouse issue links to
  github.com/Datastore/Datastore — a dead host. Those point at upstream's own
  tracker and are restored, alongside the contributors list, sql.clickhouse.com
  and the ClickHouse Inc copyright: attribution is theirs, not ours to rename.

base/glibc-compatibility/memcpy/memcpy.h is deleted, not kept: upstream dropped
it for LLVM-libc's, and our only change to it was a comment rebrand.
2026-07-26 14:47:43 -07:00
Raúl MarínandGitHub 9db0c8259b Merge pull request #109825 from Algunenano/macos-async-signal-safe-unwind
Support the query/memory profiler and trace_log symbolization on macOS
2026-07-21 17:57:25 +00:00
xiaobin 4d89133234 Merge branch 'master' into add_paimon_metadata_cache 2026-07-15 11:14:19 +08:00
Miсhael StetsyukandGitHub ee0de6618f Merge pull request #109675 from ClickHouse/fix-shutdown-after-startup-failure
Fix segfault due to bad shutdown ordering on startup exception
2026-07-14 19:09:42 +00:00
xiaobin fce1bd4804 Merge branch 'master' into add_paimon_metadata_cache 2026-07-15 00:18:58 +08:00
Raúl MarínandGitHub 49ca5a3ae1 Merge branch 'master' into macos-async-signal-safe-unwind 2026-07-14 11:55:32 +02:00
Raúl MarínandGitHub 6f95f18c46 Merge branch 'master' into darwin-streaming-exchange 2026-07-13 19:08:48 +02:00
XiaoBinMuandGitHub af0d67d8ab Merge branch 'master' into add_paimon_metadata_cache 2026-07-13 14:40:01 +08:00
Mikhail Artemenko 3ee4c7bfad Merge branch 'master' into streaming-task-scheduling-settings 2026-07-12 11:26:44 +00:00
Sergei TrifonovandGitHub ed9c79231f Merge pull request #108286 from ClickHouse/remove-custom-resmanager
Remove obsolete CustomResourceManager in favor of WorkloadResourceManager
2026-07-10 21:59:41 +00:00
Sema ChecherindaandGitHub 38cc9d2ac4 Merge pull request #109702 from ClickHouse/reader-executor-decryption
Decryption support and encryption-header cache for the experimental ReaderExecutor
2026-07-10 14:58:58 +00:00
Michael Stetsyuk a8301c859b Merge remote-tracking branch 'origin/master' into fix-shutdown-after-startup-failure
# Conflicts:
#	programs/server/Server.cpp
2026-07-10 12:12:59 +00:00
garrettthomas 0db3b27e35 fix server_startup_and_shutdown_logs 2026-07-09 16:26:49 -07:00
serxa 6d90c31647 Merge remote-tracking branch 'origin/master' into remove-custom-resmanager 2026-07-09 19:08:47 +00:00
Raúl Marín 51e29c630d Rename hasPHDRCache to hasAsyncSignalSafeUnwind; return true on macOS (backtrace-based unwinding) 2026-07-08 16:48:14 +02:00
Raúl Marín 662ccad5a1 Gate streaming exchange on OS_LINUX||OS_DARWIN, not unconditionally (keep FreeBSD/SunOS unsupported) 2026-07-08 15:14:06 +02:00
Raúl Marín ff89ccc8a9 Support streaming distributed exchange on macOS (self-pipe instead of eventfd) 2026-07-08 14:32:01 +02:00
Sema Checherinda 999fca5a5d feat: cache encryption headers to skip re-reads (ReaderExecutor)
On the experimental ReaderExecutor path, `initDecryption` read the encryption
header (`N * Header::kSize` bytes) from the source on every open of an encrypted
file — a network GET per column-stream open. Add a process-global cache of the
raw header bytes, keyed by the file's storage path, so repeated opens of the same
file skip that read.

The cache stores opaque bytes (not parsed `FileEncryption::Header`s), so it has no
SSL dependency and compiles in every build; on a hit the executor re-parses the
tiny header. It is a `CacheBase` (SLRU), sized by the new
`encryption_header_cache_size` server setting (default 50 MiB, hot-reloadable) and
cleared by `SYSTEM DROP ENCRYPTION HEADERS CACHE` (also cleared with the other
path-keyed caches, since a reused path could otherwise return stale headers).

Only disk reads populate/consult it: `DiskEncrypted::prepareRead` marks the
pipeline via `ReadPipeline::allowEncryptionHeaderCache`, and the executor receives
the cache only then — url / external-storage reads never cache, so a reused
external path can never serve stale headers.

Adds `CurrentMetrics::EncryptionHeaderCache{Bytes,Entries}`,
`ProfileEvents::EncryptionHeaderCache{Hits,Misses}`, a gtest and a functional test
(`04509`), and the `SYSTEM_DROP_ENCRYPTION_HEADERS_CACHE` access type.
2026-07-07 20:29:40 +02:00
Michael Stetsyuk 0bf318a5c3 Fix segfault due to bad shutdown ordering on startup exception 2026-07-07 15:47:15 +00:00
XiaoBinMuandGitHub 2c70514b3c Merge branch 'master' into add_paimon_metadata_cache 2026-07-07 16:05:09 +08:00
xiaobin 66156fd959 Merge branch 'master' into add_paimon_metadata_cache 2026-07-07 11:22:43 +08:00
Alexey MilovidovandGitHub eed120f238 Merge branch 'master' into streaming-task-scheduling-settings 2026-07-06 20:20:47 +02:00
Sema Checherinda 5ac254fbf8 Merge remote-tracking branch 'public/master' into reader-executor-long-connections 2026-07-06 17:27:31 +02:00
Mikhail ArtemenkoandGitHub 5e2e45bb4b Merge branch 'master' into streaming-task-scheduling-settings 2026-07-06 14:44:05 +02:00
serxa 8aabaa6e8a Merge remote-tracking branch 'origin/master' into remove-custom-resmanager 2026-07-03 13:43:23 +00:00
Sema Checherinda c17f1c5c57 Merge remote-tracking branch 'public/master' into chesema/remove-insert-deduplication-version
# Conflicts:
#	src/Core/ServerSettings.cpp
#	src/Storages/MergeTree/MergeTreeSettings.cpp
2026-07-03 15:31:37 +02:00
Azat KhuzhinandGitHub 88bfbcf39b Merge pull request #105056 from azat/shard-profile-events-per-cpu
Make Profile Events ±30x faster by using Per CPU atomics for server-wide and users
2026-07-03 06:37:43 +00:00
xiaobin a7abce46f4 Merge branch 'master' into add_paimon_metadata_cache 2026-07-02 20:32:17 +08:00
Azat Khuzhin 04feb2203f Optimize Profile Events by using Per CPU counters for server-wide and users
Note, I've tried to use librseq, but looks like it does not worth it,
for read it may get up to 16%, while contended atomic vs uncontended is
30x.

Though rseq can also help with contention between write and read sides,
but it is also neglectible, it is only around 40ns win for p99+, while
complete read of all counters (for metric_log) is 2us vs 38us, yes, it
is 19x more, but it is still only 38us, and unlikely the contention is a
problem there.

v2: switch users to shared counter - 30x faster
v3: use NPROC over MAX_CPUs
v4: remove atomic pointer in ctor
v5: rename shard → per_cpu
v6: cache-line-align ProfileEvents per-CPU rows
v7: Add benchmark for ProfileEvents under 500 threads × 50 groups
v8: Drop librseq from ProfileEvents per-CPU sharding (does not give lots of benefit)

    per-cpu atomic
    ==============
    Benchmark                                               Time             CPU   Iterations UserCounters...
    ---------------------------------------------------------------------------------------------------------
    BM_ProfileEvents/1000/process_time/real_time        0.948 ms         26.1 ms          694 groups=50 incs/thread/step=1.44092 items_per_second=527.21M/s ns/inc=1.89678ns threads=500 users=1
    BM_ProfileEvents/10000/process_time/real_time        5.13 ms          213 ms          110 groups=50 incs/thread/step=90.9091 items_per_second=975.257M/s ns/inc=1025.37ps threads=500 users=1
    BM_ProfileEvents/100000/process_time/real_time       38.3 ms         1862 ms           18 groups=50 incs/thread/step=5.55556k items_per_second=1.30592G/s ns/inc=765.745ps threads=500 users=1

    rseq
    ==============
    Benchmark                                               Time             CPU   Iterations UserCounters...
    ---------------------------------------------------------------------------------------------------------
    BM_ProfileEvents/1000/process_time/real_time        0.875 ms         22.3 ms          753 groups=50 incs/thread/step=1.32802 items_per_second=571.651M/s ns/inc=1.74932ns threads=500 users=1
    BM_ProfileEvents/10000/process_time/real_time        4.64 ms          175 ms          156 groups=50 incs/thread/step=64.1026 items_per_second=1076.95M/s ns/inc=928.552ps threads=500 users=1
    BM_ProfileEvents/100000/process_time/real_time       34.6 ms         1576 ms           20 groups=50 incs/thread/step=5k items_per_second=1.44688G/s ns/inc=691.142ps threads=500 users=1

v9: Add user_profile_events_per_cpu server setting
v10: Cache-line-align the per-user ProfileEvents counter allocation
v11: Resolve sched_getcpu once per logical ProfileEvents increment
v12: More benchmarks
2026-07-02 09:40:48 +02:00
xiaobin d34b3fddb1 Merge branch 'master' into add_paimon_metadata_cache 2026-07-02 13:44:25 +08:00
uber 14978321fd Merge remote-tracking branch 'origin/master' into uberdever/feature/changeable-to-throw-settings 2026-07-01 15:53:03 +03:00
Sema Checherinda ce3b30e0f8 Merge remote-tracking branch 'public/master' into reader-executor-long-connections 2026-07-01 09:48:40 +02:00
Sema Checherinda bbdac6cf6f Cover the non-replicated deduplication window in migration guidance
Address review: the fail-closed migration message for
`insert_deduplication_version` only described the replicated, time-based
window (`replicated_deduplication_window_seconds`). Non-replicated
`MergeTree` deduplication uses `MergeTreeDeduplicationLog`, whose window is
count-based (`non_replicated_deduplication_window` blocks) and persisted on
local disk; a one-hour wait does not drain it. Without running
`compatible_double_hashes` for at least that many inserts, stale legacy
block ids can survive the upgrade and a retried insert may be accepted as
new on non-replicated tables.

Extend both the startup exception text and the `insert_deduplication_version`
server-setting description to spell out the count-based non-replicated window.
2026-06-30 18:00:33 +02:00
Sema Checherinda 3544cfd0ba Merge remote-tracking branch 'public/master' into chesema/remove-insert-deduplication-version
# Conflicts:
#	src/Storages/MergeTree/MergeTreeSink.cpp
2026-06-30 17:58:46 +02:00
Alexey Milovidov a26c451521 Merge remote-tracking branch 'origin/master' into add-executable-udf-drivers 2026-06-29 18:29:53 +00:00
uber da8ade3c76 Make entity to_throw limits reloadable
Squashes prior branch commits:

- Make `to_throw` settings changeable without restart

- Respect settings in local `clickhouse`

- Add runtime settings update test

- Extend tests and respect `server_settings`

- Condense duplicated `Context` code with X-macros

- Fix style check and warning format messages
2026-06-29 13:55:49 +03:00
XiaoBinMuandGitHub 4c5e869384 Merge branch 'master' into add_paimon_metadata_cache 2026-06-29 12:07:59 +08:00
Alexey MilovidovandGitHub a0f19a04f0 Merge pull request #104976 from ClickHouse/memory-worker-rss-speculative-reserve
Speculatively reserve growth headroom on top of observed RSS
2026-06-28 02:43:07 +00:00
serxa 517c2115c1 Merge remote-tracking branch 'origin/master' into remove-custom-resmanager 2026-06-27 23:28:54 +00:00
Azat KhuzhinandGitHub 6155bc4b67 Merge pull request #106055 from azat/per-cpu-untracked-memory
Bound untracked memory per-CPU to avoid overcommit and OOMs
2026-06-27 16:04:41 +00:00
Azat KhuzhinandClaude Opus 4.8 c58110b0af Refresh the cached memory-sample config when the tracker parent or config changes
getEffectiveSampleProbability reads only ThreadStatus's cached sample config, so it
goes stale whenever the effective tracker parent/config changes without a refresh:
threads parented to total_memory_tracker with no query context, the initiating thread
after ProcessList::insert applies the query's SETTINGS (e.g. memory_profiler_sample_probability
in the SQL SETTINGS clause), detach reparenting back to total_memory_tracker, the main
thread after the server applies total_memory_tracker_sample_probability (set after
MainThreadStatus was created), and MemoryTrackerSwitcher scopes — each kept a stale
value and stopped emitting MemorySample. Re-resolve the cache at every such point:
ThreadStatus construction, applyGlobalSettings (every attach), applyQuerySettings,
ProcessList::insert, detachFromGroup, MemoryTrackerSwitcher (save/re-resolve/restore),
and Server after the total-sampler setters.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-27 14:32:44 +02:00
Azat KhuzhinandClaude Opus 4.8 1b3a93966f Bound untracked memory per-CPU to avoid overcommit and OOMs
Threads defer (de)allocations in a thread-local untracked_memory and flush to the
global MemoryTracker only past max_untracked_memory, so it undercounts by up to
nthreads * max_untracked_memory — tens of GiB with thousands of threads, enough to
overshoot max_server_memory_usage and OOM.

Bound it per-CPU instead. Each CPU keeps two counters, allocated (>= 0) and freed
(<= 0); a thread folds its untracked_memory into the counter for its sign, batched by
per_cpu_untracked_memory_thread_buffer (32 KiB), and must flush once a counter leaves
[-max_per_cpu_untracked_memory, max_per_cpu_untracked_memory]. The deferred total is
then bounded by ncpu * max_per_cpu_untracked_memory regardless of thread count, parked
threads included. The two sides are independent so a deferred free cannot admit a
deferred allocation (which the free would then strand untracked on its own flush).
max_per_cpu_untracked_memory (default 8 MiB, 0 disables) is a new server setting;
max_untracked_memory stays per-thread. Linux only (needs sched_getcpu).

v2: reimplemented — v1 bounded via sum % SLICE on one global counter, which cannot
    bound the per-CPU deferred bytes; replaced with the PerCPUMemory class.
v3: two counters instead of one signed net — a signed net let a deferred free cancel
    a deferred allocation, stranding it untracked when the free flushed.
v4: restore the per-CPU contribution unconditionally on a failed flush; a gated
    re-reserve could drop still-live bytes if another thread took the budget meanwhile.
v5: release the per-CPU contribution only in the caller, not in reserve().
v6: Rename PerCPUMemory::reserve to sync (it sets an absolute value, not a reservation)
v7: Rename net_per_cpu member to slots

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-27 14:32:43 +02:00
Sema Checherinda 398b7ab1cb Merge remote-tracking branch 'public/master' into chesema/remove-insert-deduplication-version 2026-06-26 15:26:49 +02:00
Sema Checherinda 88317be1f3 docs: clarify the insert_deduplication_version migration window
The fail-closed startup message and the setting doc told operators to run
`compatible_double_hashes` for "the longest deduplication window", which is
ambiguous and reads as the week-long async-block retention. The unified hashes
the unified-only build relies on are retained for
`replicated_deduplication_window_seconds` (one hour by default), and the default
windows keep all inserts for that window, which is considered enough for an
insert retry loop. State the one-hour sync window explicitly so the migration
guidance is unambiguous.
2026-06-26 14:32:10 +02:00
XiaoBinMuandGitHub cdf99c5d78 Merge branch 'master' into add_paimon_metadata_cache 2026-06-26 09:45:31 +08:00
Alexey MilovidovandClaude Opus 4.8 ce71735516 Merge remote-tracking branch 'origin/master' into add-executable-udf-drivers
Resolve include-region conflicts in programs/local/LocalServer.cpp and
programs/server/Server.cpp: master added <Functions/pointInPolygon.h>
and this branch added <Functions/UserDefined/UserDefinedSQLFunctionFactory.h>
at the same location; keep both (both are used in each file).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-25 21:23:28 +00:00
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
Nihal Z. Miaji fa7d37fca3 Merge branch 'master' into pointinpolygon-shared-bounded-cache 2026-06-24 21:30:55 +00:00