Repository navigation
Native Common Virtuals for NATS - #101139
Conversation
|
Workflow [PR], commit [8692a7e] Summary: ❌
AI ReviewSummaryThis PR adds Findings
Tests
ClickHouse Rules
Final Verdict
|
| { | ||
| auto all_columns = metadata->getColumns().get(options); | ||
| const auto & common_virtual_columns = IStorage::getCommonVirtuals(); | ||
| const auto common_virtual_columns = storage.getCommonVirtuals(); |
There was a problem hiding this comment.
StorageSnapshot currently snapshots metadata and virtual_columns in the constructor, but common_virtual_columns is re-read from storage.getCommonVirtuals() inside each accessor. After this PR, common virtuals are mutable (MultiVersionVirtualsDescriptionPtr), so a concurrent setVirtuals can change common virtuals mid-query and make one StorageSnapshot observe mixed versions.
That can lead to inconsistent behavior in a single query path (e.g. getColumns and later check seeing different common virtual sets). Please snapshot common virtuals in StorageSnapshot ctor (store a VirtualsDescriptionPtr common_virtual_columns) and use that member in all methods, same as virtual_columns.
LLVM Coverage Report
Changed lines: 20.83% (5/24) · Uncovered code |
…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]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Part of #100766
Version info
26.4.1.482