Skip to content

Native Common Virtuals for Kafka - #101138

Merged
Michicosun merged 3 commits into
masterfrom
native_common_virtuals/Kafka
Apr 1, 2026
Merged

Michicosun merged 3 commits into
masterfrom
native_common_virtuals/Kafka

Conversation

@Michicosun

@Michicosun Michicosun commented Mar 29, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Part of #100766

Version info

  • Merged into: 26.4.1.483

@clickhouse-gh

clickhouse-gh Bot commented Mar 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2b7aaea]

Summary: ❌

job_name test_name status info comment
Stress test (arm_msan) failure
Cannot start clickhouse-server FAIL cidb, issue
Parse failure error failure cidb, issue
Check failed failure cidb, issue

AI Review

Summary

This PR adds Kafka support for native common virtuals by introducing _table in Kafka virtual columns and wiring population in both StorageKafka read paths. The index shifts for _raw_message/_error are internally consistent, and no correctness, safety, concurrency, or performance regressions were identified in the changed code.

Missing context
  • ⚠️ Full CI is still in progress (several checks pending), so final runtime validation is not yet available.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 29, 2026
@CheSema CheSema self-assigned this Mar 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.20% +0.10%
Functions 90.90% 90.90% +0.00%
Branches 76.70% 76.70% +0.00%

Changed lines: 97.67% (42/43) · Uncovered code

Full report · Diff report

@Michicosun
Michicosun added this pull request to the merge queue Apr 1, 2026
Merged via the queue into master with commit afb746d Apr 1, 2026
159 of 160 checks passed
@Michicosun
Michicosun deleted the native_common_virtuals/Kafka branch April 1, 2026 11:04
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 1, 2026
lilredbot pushed a commit to JTCunning/ClickHouse that referenced this pull request Nov 4, 2026
…og sources

Since the "native common virtuals" series (ClickHouse#101138 for Kafka, ClickHouse#101411 for
RabbitMQ, ClickHouse#101139 for NATS, ClickHouse#101006 for FileLog) the streaming sources
fill the `_table` virtual column inside the per-row (NATS: per-message)
loop with `getStorageID().getTableName()`. `IStorage::getStorageID()`
locks the table-wide `id_mutex` and copies the `StorageID`, and all
reader-place virtuals are materialized for every row whether or not the
query selects `_table`, so every consumer thread of one table took the
same mutex for every row and consumers of one table serialized on it
(ClickHouse#120032). The Kafka, StorageKafka2 and RabbitMQ dead-letter branches did
the same once per failed message.

Take one `StorageID` snapshot plus a `Field` with the table name before
the consume loop and fill `_table` / the dead-letter element from it.
A block now carries the table name read when the block started, which is
the identity `streamToViews` inserts the block under.

Measured with a bpftrace uprobe on `IStorage::getStorageID` while a
materialized view drains the table: calls made by the source function
itself go from one per row (100000 for 100000 Kafka / StorageKafka2 /
FileLog rows, 20000 for 20000 NATS / RabbitMQ rows) to one per block
(2-8 for Kafka, StorageKafka2, FileLog and NATS; 261-371 for RabbitMQ,
which drains in small blocks).

The existing virtual-column tests now also check `_table` for Kafka (both
engines), RabbitMQ, NATS and FileLog.

Closes ClickHouse#120032

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

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants