Skip to content

[pull] master from ClickHouse:master - #4

Merged
pull[bot] merged 3 commits into
erickirt:masterfrom
ClickHouse:master
Dec 10, 2024
Merged

pull[bot] merged 3 commits into
erickirt:masterfrom
ClickHouse:master

Conversation

@pull

@pull pull Bot commented Dec 10, 2024 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull Bot added the ⤵️ pull label Dec 10, 2024
@pull
pull Bot merged commit 3c7d675 into erickirt:master Dec 10, 2024
pull Bot pushed a commit that referenced this pull request Dec 24, 2024
…working-backup-sync-4

Corrections after reworking backup/restore synchronization #4
pull Bot pushed a commit that referenced this pull request Aug 20, 2025
Merge from master && fix formats(date, dict)
pull Bot pushed a commit that referenced this pull request Nov 19, 2025
…y names

When ClickHouse encounters a distributed table directory with a name that:
- starts with the pattern `shardN_all_replicas` (e.g., `shard3_all_replicas_bkp`)
- but doesn't end with exactly `_all_replicas`

It would crash with a segmentation fault due to out-of-bounds array access.

Trace example:
```
* thread #1, name = 'clickhouse-serv', stop reason = signal SIGSEGV
  * frame #0: 0x000000001194481b clickhouse-server`DB::Cluster::Address::Address(DB::Cluster::Address const&) + 27
    frame #1: 0x0000000011944550 clickhouse-server`void std::__1::vector<DB::Cluster::Address, std::__1::allocator<DB::Cluster::Address> >::__push_back_slow_path<DB::Cluster::Address const&>(DB::Cluster::Address const&&&) + 208
    frame #2: 0x00000000129a6c35 clickhouse-server`DB::StorageDistributed::parseAddresses(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const + 3349
    frame #3: 0x00000000129a589b clickhouse-server`DB::StorageDistributed::getDirectoryQueue(std::__1::shared_ptr<DB::IDisk> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 3675
    frame #4: 0x00000000129a3f22 clickhouse-server`DB::StorageDistributed::initializeDirectoryQueuesForDisk(std::__1::shared_ptr<DB::IDisk> const&) + 2082
    frame #5: 0x000000000f681c48 clickhouse-server`DB::ThreadPoolCallbackRunnerLocal<void, ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true> >, std::__1::function<void ()> >::operator()(std::__1::function<void ()>&&, Priority)::'lambda'()::operator()() + 136
    frame #6: 0x000000000f68286c clickhouse-server`std::__1::packaged_task<void ()>::operator()() + 44
    frame #7: 0x000000000d83335b clickhouse-server`ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true> >::ThreadFromThreadPool::worker() + 2395
    frame #8: 0x000000000d839e23 clickhouse-server`void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<ThreadFromGlobalPoolImpl<false, true>::ThreadFromGlobalPoolImpl<void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true> >::ThreadFromThreadPool::*)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true> >::ThreadFromThre
adPool*>(void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true> >::ThreadFromThreadPool::*&&)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true> >::ThreadFromThreadPool*&&)::'lambda'(), void ()> >(std::__1::__function::__policy_storage const*) + 99
    frame #9: 0x000000000d830602 clickhouse-server`ThreadPoolImpl<std::__1::thread>::ThreadFromThreadPool::worker() + 2242
    frame #10: 0x000000000d8379ba clickhouse-server`_ZNSt3__114__thread_proxyB6v15007INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEMN14ThreadPoolImplINS_6threadEE20ThreadFromThreadPoolEFvvEPSA_EEEEEPvSF_ + 90
```
pull Bot pushed a commit that referenced this pull request Dec 22, 2025
Docs: move aggregate function docs to source (#4)
pull Bot pushed a commit that referenced this pull request Mar 31, 2026
## #1: Cross-test ownership ratio (find_tests.py)

Replace plain `1/width` scoring with `1/(width × region_test_count)` where
`region_test_count = uniqExact(test_name)` for each region.  A region covered
by 1 test scores 1000× higher than one covered by 1000 tests, naturally
eliminating the hot-region problem without a hard cap.

## #2: Branch direction (LLVMCoverageMapping + coverage_log)

Parse `BranchRegion` (LLVM kind=4) in `readLLVMCoverageMapping`.  Format:
kind-marker → true_counter → false_counter → line/col, producing two
`CoverageRegion` entries with `is_branch=true` and `is_true_branch` set.
Added `branch_flags Array(UInt8)` to `system.coverage_log` (0=code, 1=true,
2=false).  Tests that covered both sides of a changed condition now carry that
information for smarter ranking.

## #3: Indirect call targets (coverage.h/cpp + CoverageCollection)

Read `LLVMProfileData::Values` (LLVM value profiling, kind IPVK_IndirectCallTarget)
to capture which concrete functions were called via virtual dispatch or function
pointers.  Each observation: `(caller_name_hash, caller_func_hash, callee_offset,
call_count)` where `callee_offset = callee_abs − binary_load_base` (from
`/proc/self/maps`), stable across ASLR restarts.  Flushed alongside coverage
counters into `system.coverage_indirect_calls`.  Fixes the fundamental gap where
a test covering `IStorage::read` cannot be distinguished from a test specifically
dispatching to `StorageMergeTree::read`.

## #4: XRay call-depth tracking (coverage.h/cpp + cmake/sanitize.cmake)

New CMake option `WITH_COVERAGE_XRAY=ON` enables `CLICKHOUSE_XRAY_INSTRUMENT_COVERAGE`.
At test start, activates XRay (`__xray_patch`) with a handler that maintains per-thread
relative call depth.  On first activation, builds a `(xray_function_id → profile_data_index)`
map by resolving each function via `__xray_function_address(id)` + `dladdr()` → symbol name
→ FNV64 hash → match against `LLVMProfileData::NameRef`.  This solves the PIE
`FunctionPointer=0` limitation: XRay provides real runtime text addresses where
`LLVMProfileData::FunctionPointer` is always null.  When enabled, `min_depth` in
`CovCounter` contains actual call depth; otherwise falls back to call-count proxy.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
pull Bot pushed a commit that referenced this pull request May 13, 2026
Under x86-64-v3 the `ColumnString` prologue in
`FunctionRandomString::executeImpl` is emitted with YMM stores
(`vmovups ymmword`, `vpbroadcastq`) for the `Chars`/`Offsets` init.
The compiler then has to emit a `vzeroupper` before every virtual call to
`length_column.getUInt(row_num)` inside the per-row loop in case the callee
expects clean AVX/SSE state.  The extra ~6-cycle transition × 100M rows
regresses `random_string` perf test #4 (`randomString(rand() % 10)`) ~15%.

Compiling this file at v2 keeps the SSE-only wrapper codegen used by master,
which avoids any AVX state and therefore no `vzeroupper`.  The hot AVX2 byte
generator `RandImpl::execute` lives in `FunctionsRandom.cpp` and remains
compiled at v3.

Combine the new entry with the existing `FunctionsStringDistance.cpp` rule
under a shared comment block.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
pull Bot pushed a commit that referenced this pull request May 13, 2026
`getReturnTypeImpl` already constrains the second argument of
`kostikConsistentHash` / `jumpConsistentHash` to an integer type, so the
constant bucket count can be read directly via `IColumn::getInt` /
`getUInt` instead of materialising an intermediate `Field`.

Apart from being a small simplification this fixes a `-march=x86-64-v3`
regression: `Field` is a 32-byte object, and `clang` lowered the
`Field buckets_field = (*arguments[1].column)[0]` copy to YMM
`vmovups`-pairs.  The dirtied AVX upper state then forced `vzeroupper`
before every per-row call to the (separately compiled, scalar-only)
`ConsistentHashing` helper, regressing
`consistent_hashes #0/#2/#4` ~10–13% on AMD release.

After the refactor the per-row hot path no longer touches YMM at all;
the remaining `vzeroupper` instructions left in the function body are in
cold exception-construction paths and execute as no-ops because the
upper YMM state is already clean.

On Sapphire Rapids LTO (100M rows):
  - master:                 0.211–0.215 s
  - PR (no fix):            0.227–0.242 s  (+11 %)
  - PR + this refactor:     0.211–0.214 s  (matches master)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
pull Bot pushed a commit that referenced this pull request May 24, 2026
The point-lookup queries (#4-#7) in apply_patch_parts_join produced
18-30% test noise because the four UPDATE statements that build the
patch parts ran with default parallelism. Parallel threads racing into
the patch builder produce different patch-part split boundaries on
every run, which changes how many patch granules a point lookup at
id=5000000 ends up reading. Per-server timing then depends on the
random split, not on the code being measured.

Force INSERT and UPDATE to use a single thread plus a block size large
enough to fit each whole patch, so the patch-part layout is the same
on every run. Locally verified deterministic over 20 cycles. Setup
time goes from ~4.2s to ~6.3s. Scan queries (#0-#3) still detect
patch-apply-path regressions as before.

Refs ClickHouse#100759.
pull Bot pushed a commit that referenced this pull request Jun 6, 2026
ClickHouse#106278 tried to remove the LIMIT-without-ORDER-BY non-determinism by
sampling with WHERE cityHash64(WatchID) % N = 0. Post-merge master data
showed it did not work: it made the measured queries scan the whole table on
every run, so instead of reducing the noise it regressed it badly:

  classification #0: 6.5% -> 76% noisy
  classification #1:  10% -> 90% noisy

(#2/#3/#4 were already clean.)

Materialize the deterministic subset once into its own single-part table
(single-threaded insert + OPTIMIZE FINAL) and measure over that, so the
determinism lives in the setup (like ClickHouse#106249 for reading_from_file) and the
measured queries read only the subset instead of rescanning the source.
pull Bot pushed a commit that referenced this pull request Jun 15, 2026
In case #4 the previous assertion only checked for `BEL` on stderr; it
never verified that the query actually failed. If `throwIf` semantics
change or the query is rewritten so it no longer errors, case #4 could
silently keep printing `BEL` (since the query runs longer than the
threshold) and the test would still pass — losing the "chime on
failure" coverage this case was added to provide.

Now case #4 explicitly:
  1. asserts a non-zero exit code (query must have failed),
  2. asserts that `'expected error'` is present in stderr (the error
     came from `throwIf` and not from an unrelated client/network
     issue),
  3. only then checks for `BEL`.

Any of the first two conditions failing prints a diagnostic
"FAIL: ..." line which won't match the reference, so the test fails
loudly with a clear reason.

Issue: ClickHouse#92718
PR: ClickHouse#104545
Review thread: ClickHouse#104545 (comment)
pull Bot pushed a commit that referenced this pull request Jun 22, 2026
…plication handling

- #10 (major): add unique_key_bitmap_cache_size_bytes to collectChangeableServerSettings
  so system.server_settings reflects the live cache size after reload config.
- #4: revert MutateTask delete-bitmap preservation. Mutation x bitmap (preserve AND
  row-offset reconciliation) is write-integration territory; no production path writes
  a bitmap in this slice, so the code was never exercised.
- #9 (blocker): UNIQUE KEY is MergeTree-only today, so no bitmap traverses replication.
  Leave a TODO to gate sidecar transfer behind a new protocol version when
  ReplicatedMergeTree support lands, instead of building untestable machinery now.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
pull Bot pushed a commit that referenced this pull request Jul 1, 2026
…acles)

Bump the SQLancer provider to ClickHouse/sqlancer `main` after PR #4
(ClickHouse/sqlancer#4): the wrong-result oracle
suite with 31 oracles, a recursive type system, and the
`com.clickhouse:client-v2` (RowBinary) transport replacing `clickhouse-jdbc`.

Docker image (`ci/docker/sqlancer-test/Dockerfile`):
- Bump the cloned commit to `a62ea509ee53862b5dd37f452e8c2edce8038951`.
- The new `pom.xml` targets Java 25, which Ubuntu 22.04 `default-jdk`/`maven`
  cannot build, so install Temurin JDK 25 (Adoptium) and Maven 3.9.9, and add
  `-Djacoco.skip=true` to the build (jacoco 0.8.12 rejects Java 25 classfiles).

Job script (`ci/jobs/sqlancer_job.sh`):
- Apply the provider's server-side config overrides from
  `.claude/clickhouse-config/` (logger to `warning`, remove `system.trace_log`,
  TTL the system-log tables, pin `async_insert` off) by starting the server
  from a directory containing `config.d/`; the embedded default `config.xml`
  still merges `config.d/*.xml` relative to the server CWD.
- Replace the per-oracle loop with a single combined run of all 25 oracles
  bounded by one wall-clock timeout, matching the upstream
  `.claude/run-sqlancer.sh` reference, and enable `--random-session-settings`.
pull Bot pushed a commit that referenced this pull request Jul 1, 2026
…pr4-driver-oracles

Update SQLancer to ClickHouse/sqlancer PR #4 (client-v2 driver, 25 oracles)
pull Bot pushed a commit that referenced this pull request Aug 3, 2026
Exclude implicitly created skip indices from system.tables.skipping_indices_types
pull Bot pushed a commit that referenced this pull request Aug 29, 2026
…is not an entry

**Same-cycle detection now has a durable source.** `cycle_entries` was built
from what the changelog still shows - the section, this run's raw entries, the
recorded deletions, the revert graph - and an entry pruned as insignificant on
an earlier run leaves none of those. A revert of it arriving weeks later
therefore looked like a revert of an earlier release: deleting it was rejected,
or keeping a visible bullet for a change with no net effect was accepted.

`release_range_prs` answers the question from git instead: the pull requests
merged into master since the cycle's `vX.Y.1.1-new` tag, from both subject
shapes the repository uses. Git remembers the range whatever the changelog did
with it. `--first-parent`, so the walk stays on master's own commits - a
contributor branch can carry merges of pull requests of the contributor's
*fork*, and there are five such numbers in the 26.8 range (`Merge pull request
#4 from someone/...`), which mean nothing here. 2277 pull requests for that
range, in 0.3s.

**And the limitation from the previous round is closed rather than documented.**
A re-applier that also reverted something of an earlier release has a change of
its own; the link it contributes to the entry it brought back is an annotation
on someone else's bullet and cannot stand in for that. It is checkable without
forbidding a legitimate merge, by asking for *some other* bullet rather than
for a bullet of its own: a section 7 merge into a third entry still passes,
while collapsing the entry into the annotation does not.

Two tests added. The pruned-entry one runs the same input with and without the
range, so it shows both the old verdict and the new one; the annotation one
also asserts that the legitimate merge is still accepted.
pull Bot pushed a commit that referenced this pull request Aug 29, 2026
…ategory

**`release_range_prs` read every `(#N)` in a subject.** A squashed revert
quotes the original title, `Revert "Something (ClickHouse#90000)" (ClickHouse#115800)`, and the
quoted number would put a pull request of an earlier release into this range -
the very distinction the caller uses the range for, so a revert of it would
look like something this release cancels out rather than a user-visible
reversal. Both shapes are now anchored: the squash number ends the subject, the
`Merge pull request #N` one starts it.

That shape does not occur in the last 60000 commits of this repository, where
reverts land as merge commits, so this is hardening rather than a live bug. The
anchored form is the right parse either way, and the regression pins it along
with a fork's own `Merge pull request #4` appearing mid-line.

**A sibling moved between categories made the merge impossible.** The category
check demanded the recorded header while the shared-bullet rule demanded a
merge into the surviving bullet, so once an edit had moved that bullet the two
contradicted each other and no edit could pass. The expected category is now
the surviving bullet's current one when there is a sibling to merge into, and
the recorded one otherwise: the check follows the bullet rather than a
remembered header.

The two rules then compose instead of fighting - moving the whole merged bullet
elsewhere stays legal, while leaving the survivor and restoring the entry beside
it under the old header is rejected, which the test asserts.
pull Bot pushed a commit that referenced this pull request Sep 29, 2026
Query #7 of tests/performance/array_first_last.xml (arrayLast over
Array(Array(UInt64))) takes a different time in each server process of
the same build. In 14 days of Performance Comparison runs on amd it moved
by more than 15% between the two servers in 50 of 633 runs, 36 of them
master against master, while #6 (arrayFirst over the same column) moved
in 0 of 641 and the tuple queries #4/#5 in 2 and 3; arm is quiet. Per
run, #6 and #7 move in opposite directions (r = -0.53 over 524 amd runs;
in 33 of the 37 runs where #7 moved by more than 15%, #6 moved the other
way), while #4/#5 move together (r = +0.42).

Each nested_values row holds 32 inner arrays of 2 UInt64, so rows are 256
bytes apart in the inner offsets and 512 bytes apart in the data. #6 and
#7 read one inner array per row, so for the whole query every row is read
at the same position modulo 256/512 bytes, i.e. at the same few offsets
inside every memory page. Which offsets those are depends on where the
column is allocated: jemalloc is built with cache_oblivious, which puts
every large allocation at a random multiple of 64 bytes inside its first
page, and the table is filled once per server. So each server reads the
column at its own fixed page offsets.

Fill nested_values with 31 inner arrays per row. Rows are then 248/496
bytes apart and the read position walks through every offset of the page
within one query, so the timing no longer depends on the allocation. The
query texts and the per-row work (one copy of a 2-element array per row,
250000 rows) are unchanged.

Local check with the official master build 26.10.1.906 on a Xeon 6975P-C:
16 separately filled copies of the table per arm in one server, measured
round-robin for 20 rounds. This machine does not show the spread with
either layout (#7 across copies: 14.14-14.68 ms with 32 elements and
random allocation offsets, 13.93-14.27 ms page-aligned with
MALLOC_CONF=cache_oblivious:false, 13.95-14.32 ms with 31 elements), so
it cannot confirm the mechanism and the change rests on the CI data. The
level of #7 stays (31 vs 32 elements: 0.98x); #7/#6 goes from 1.11 to
1.03.

Related: ClickHouse#120510

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pull Bot pushed a commit that referenced this pull request Sep 29, 2026
`lowerUTF8`/`upperUTF8` of `mixed_01_clustered` (queries #4/#5) ran at one of
two levels per server process in Performance Comparison, about 1900 minor
page faults and 2 ms of system time apart, which is ~17% of the 12 ms arm
query. That column keeps all its non-ASCII rows in the first block, so it is
the only one whose query takes both result reservations of
`LowerUpperUTF8Impl`: the non-ASCII path rounds up to a power of two, 16 MiB
for a 65536-row block of 128-byte values plus 127 bytes of padding, while the
all-ASCII path reserves exactly 8 MiB + 127 bytes. perf.py purges jemalloc
before every run, so each run touches its pages afresh.

Run the test at the default block size, 65409 rows (`DEFAULT_BLOCK_SIZE`,
65536 minus that padding): a block stays below 8 MiB and both paths get
8 MiB. `mixed_01_block_tail` follows the block size, so its 64 non-ASCII rows
are still the last rows of every full block. Row length, block count, query
order and every case are unchanged.

Local A/A with the official master build and perf.py: the old fixture shows
the split in 33 of 40 server processes, the new one in none, and no query of
the test moved in 12 complete-test repetitions per fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pull Bot pushed a commit that referenced this pull request Sep 29, 2026
…ion over a `Nullable` argument

The `-If` null adapters merged the null map with the condition into a buffer
sized by the absolute end row of the call and filled only `[row_begin, row_end)`.
Aggregation in order calls `addBatchSinglePlace` once per key interval, and
window frames once per frame update, so with 8-row groups every call asked for
up to 64 KiB to use 8 bytes. The merges the nested functions do for themselves
(`SingleValueData`, `groupBit*`, the simple moments, `regr_*`,
`timeSeriesLastTwoSamples`) were sized the same way.

On x86_64 every such request above 32 KiB exceeds jemalloc's thread cache
limit (`opt_tcache_max`) and takes the arena large-extent path, whose cost
depends on the state of the process. On aarch64 (64 KiB pages) these sizes are
small size classes served from the thread cache. That is why queries #2 to #5
of `tests/performance/aggregation_in_order_if_null_map.xml` are unstable on
the amd runners only: in the last 14 days CIDB has 2008 of the test's 2174 amd
`unstable` verdicts on #2 to #5, and 8 on arm in total.

With a single `Nullable` argument no merged map is needed:
`addBatchSinglePlaceNotNull` takes the null map and the condition column
separately, and every implementation handles `if_argument_pos`
(`AggregateFunctionIf` already calls them all that way). So
`AggregateFunctionIfNullUnary` with a non-`Nullable` condition passes the
value's null map and the condition at position 1, and
`AggregateFunctionIfNullVariadic` with exactly one `Nullable` argument passes
that argument's null map to the nested `-If` function, which applies the
condition. The merges those calls reach allocate `row_end - row_begin` bytes
and call their kernels with pointers rebased by `row_begin`, as `sum` and
`avg` already do. The same rows are added in the same order, so the results
do not change. Two or more `Nullable` arguments (query #5, `corr(x, w)`), a
`Nullable` condition of a one-argument `-If` function and the TimeSeries
array merges keep their merged buffer.

Measured on a release build (x86_64, `max_threads` 8), base / this change,
per run of each query of the test:
- jemalloc large allocations above 32 KiB: #0 703 / 703, #1 714 / 714,
  #2 302182 / 703, #3 302142 / 663, #4 229046 / 1718, #5 115413 / 115413;
- CPU profiler samples in the jemalloc large-extent path: #2 33% / 0.9%,
  #3 31% / 0.5%;
- perf.py median of 13 runs, two alternating rounds (ms): #2 38.2, 39.8 /
  24.6, 21.7; #3 39.0, 40.2 / 21.3, 19.8; #4 44.3, 45.4 / 28.3, 25.9;
  #0, #1 and #5 unchanged;
- `minIf(x, cond) OVER (ORDER BY k ROWS BETWEEN 100 PRECEDING AND CURRENT
  ROW)` over 1M rows: 340 / 166 ms, and `sumIf(y, cn)` over a `Nullable`
  condition: 301 / 89 ms;
- aggregation without keys over the same table: 12.2 / 12.3 ms.

Query #0, flagged on ClickHouse#118490,
never had such a buffer and is not changed here.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118490&sha=8ded98e22889e53dd536b141b564e136c76482a9&name_0=PR&name_1=Performance%20Comparison%20(amd_release%2C%20master_head%2C%203%2F6)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant