Skip to content

Fix ATTACH of Kafka tables with a large kafka_num_consumers - #113390

Merged
evillique merged 3 commits into
ClickHouse:masterfrom
evillique:kafka-consumers-limit-secondary-create
Aug 11, 2026
Merged

evillique merged 3 commits into
ClickHouse:masterfrom
evillique:kafka-consumers-limit-secondary-create

Conversation

@evillique

@evillique evillique commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

kafka_num_consumers is limited by max(CPU cores, 16), so a table accepted on one server fails to ATTACH on a smaller one, or on the same one after a downscale. Validate it, and the allow_experimental_kafka_offsets_storage_in_keeper check, only at LoadingStrictnessLevel::CREATE.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed ATTACH of a Kafka table when kafka_num_consumers exceeds the limit derived from the number of CPU cores.

Version info

  • Merged into: 26.8.1.1167 (included in 26.8 and later)
  • Backported to: 26.7.4.20, 26.6.3.30, 26.5.7.38, 26.3.18.24, 25.8.30.16

@clickhouse-gh

clickhouse-gh Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [dfc2b58]

Summary: ✅


AI Review

Summary

This PR narrows the kafka_num_consumers validation so stored Kafka table definitions can still be attached after moving to a smaller server, and it adds a stateless regression test for the short ATTACH path. The kafka_num_consumers bug itself is fixed, but the PR still leaves the experimental StorageKafka2 gate bypassable through a full-definition ATTACH, and the new test still does not cover the attach_short_syntax branch that the code change depends on.

Findings
❌ Blockers
  • [src/Storages/Kafka/StorageKafkaUtils.cpp:275] [dismissed by author -- https://github.com/Fix ATTACH of Kafka tables with a large kafka_num_consumers #113390#discussion_r3738234234] The allow_experimental_kafka_offsets_storage_in_keeper guard still keys only on args.mode <= LoadingStrictnessLevel::CREATE, even though a full-definition ATTACH TABLE ... ENGINE = Kafka ... reaches this code with args.mode == LoadingStrictnessLevel::ATTACH and attach_short_syntax == false. InterpreterCreateQuery treats that path as CREATE-like user input, so a user can still introduce the Keeper-backed experimental variant with allow_experimental_kafka_offsets_storage_in_keeper = 0 just by spelling the statement as ATTACH. This should reuse the same is_fresh_definition distinction as the kafka_num_consumers check, so only short ATTACH and metadata replay skip the gate.
⚠️ Majors
  • [tests/queries/0_stateless/04662_kafka_num_consumers_attach.sql:29] [dismissed by author -- https://github.com/Fix ATTACH of Kafka tables with a large kafka_num_consumers #113390#discussion_r3738234238] The added regression test still exercises only short ATTACH TABLE kafka_many_consumers plus CREATE TABLE; the broken args.mode <= LoadingStrictnessLevel::CREATE version from the first review round would still pass it. The subtle part of the fix is the full-definition ATTACH path (attach_short_syntax == false), so without a negative ATTACH TABLE ... ENGINE = Kafka ... SETTINGS kafka_num_consumers = 1000 case there is still no regression proof for the branch this PR changed.
Final Verdict

Changes requested.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.00% 79.00% +0.00%

Changed lines: Changed C/C++ lines covered: 11/14 (78.57%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 4, 2026
@evillique evillique added pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-bugfix Pull request with bugfix, not backported by default and removed pr-bugfix Pull request with bugfix, not backported by default labels Aug 4, 2026
@evillique
evillique force-pushed the kafka-consumers-limit-secondary-create branch from bec6efc to 4f3736f Compare August 7, 2026 18:38
@thevar1able thevar1able self-assigned this Aug 7, 2026
@evillique
evillique added this pull request to the merge queue Aug 11, 2026
Merged via the queue into ClickHouse:master with commit 9bd92b7 Aug 11, 2026
695 of 706 checks passed
@evillique
evillique deleted the kafka-consumers-limit-secondary-create branch August 11, 2026 13:12
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 11, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 11, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 11, 2026
clickhouse-gh Bot added a commit that referenced this pull request Aug 11, 2026
Backport #113390 to 26.7: Fix ATTACH of Kafka tables with a large kafka_num_consumers
alexey-milovidov added a commit that referenced this pull request Aug 12, 2026
Backport #113390 to 26.5: Fix ATTACH of Kafka tables with a large kafka_num_consumers
evillique added a commit that referenced this pull request Aug 12, 2026
Backport #113390 to 25.8: Fix ATTACH of Kafka tables with a large kafka_num_consumers
evillique added a commit that referenced this pull request Aug 12, 2026
Backport #113390 to 26.3: Fix ATTACH of Kafka tables with a large kafka_num_consumers
evillique added a commit that referenced this pull request Aug 12, 2026
Backport #113390 to 26.6: Fix ATTACH of Kafka tables with a large kafka_num_consumers
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Aug 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

4 participants