Skip to content

Ignore publisher confirms with an unknown delivery tag in RabbitMQProducer - #131731

Merged
alexey-milovidov merged 5 commits into
masterfrom
fix-rabbitmq-unknown-delivery-tag
Nov 20, 2026
Merged

alexey-milovidov merged 5 commits into
masterfrom
fix-rabbitmq-unknown-delivery-tag

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

A delivery tag in an ack or nack from the broker is not guaranteed to be in delivery_record. removeRecord checked it only with chassert, then incremented or erased the end iterator, which is undefined behavior and could crash the server. For multiple, confirm everything up to the tag with upper_bound; ignore a single unknown tag with a warning.

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Fix a possible crash of the RabbitMQ table engine when the broker confirms a message with an unknown delivery tag.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/131731]

Version info

  • Merged into: 26.12.1.25-master (included in 26.12 and later)
  • Backported to: 26.11.1.2917, 26.10.8.40, 26.9.34.21, 26.8.42.19, 26.3.67.33

…oducer`

A delivery tag in an ack or nack from the broker is not guaranteed to be in `delivery_record`. `removeRecord` checked it only with `chassert`, then incremented or erased the `end` iterator, which is undefined behavior and could crash the server. For `multiple`, confirm everything up to the tag with `upper_bound`; ignore a single unknown tag with a warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov alexey-milovidov self-assigned this Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9194b26]

Summary: ✅


AI Review

Summary

The PR prevents invalid iterator operations in RabbitMQPublisher::removeRecord when publisher confirmations reference unknown delivery tags. Single confirmations preserve unrelated pending records; cumulative confirmations process records through the supplied boundary. No unresolved findings remain, and the earlier regression-coverage request is addressed. All seven regression cases passed under ASan/UBSan on revision 8a68c5a552c060a4db3b1210685781d301f3f51f; all three changed files are byte-identical at the reviewed head, 9194b26617707976aa4047f6e8057f2d8edd7feb. Test results.

Missing context / blind spots
  • ⚠️ Current-head unit tests and bugfix validation were pending at review time. No local tests were run because this checkout has no configured build or initialized dependencies. Successful current-head CI would close this execution gap; the regression evidence above comes from the preceding revision.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Nov 15, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-message-queues Message queue integrations (Kafka, RabbitMQ, NATS table engines for stream ingestion/egress). label Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 9194b2661 with master 50bbe27ba (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

11 translation units recompiled, 21 s compile time in total, 11 of them have a recent master baseline.

Job report

alexey-milovidov and others added 3 commits November 16, 2026 17:19
Address review: drive `RabbitMQProducer::removeRecord` directly with unknown
and repeated single tags, cumulative acks and nacks whose boundary tag is
missing, and an empty record set. Check that unrelated pending records remain
and negatively acknowledged payloads are queued for retry exactly once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n-delivery-tag

Master moved the publisher confirms handling (`removeRecord`, `delivery_record`, `returned`)
from `RabbitMQProducer` into the new `RabbitMQPublisher` class
(#127611). Resolve the conflict by taking master's
`RabbitMQProducer.cpp`, porting the fix for unknown delivery tags to
`RabbitMQPublisher::removeRecord`, moving the test friend declaration to `RabbitMQPublisher`,
and renaming the unit test to `gtest_rabbitmq_publisher.cpp` to drive `RabbitMQPublisher`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 20, 2026
Merged via the queue into master with commit 56687c0 Nov 20, 2026
196 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-rabbitmq-unknown-delivery-tag branch November 20, 2026 09:40
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 20, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #131731 to 26.11: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
alexey-milovidov added a commit that referenced this pull request Nov 20, 2026
Resolve the cherry-pick of #131731 to 26.8. On 26.8 the class is still called
`RabbitMQProducer` (renamed to `RabbitMQPublisher` on master), so the fix to
`removeRecord` is applied to `RabbitMQProducer.cpp`/`.h`, and the unit test is
added as `gtest_rabbitmq_producer.cpp`, adapted to the 26.8 constructor (which
takes a `shutdown_called` flag).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-ch-test-poll added a commit that referenced this pull request Nov 20, 2026
Cherry pick #131731 to 26.3: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
robot-clickhouse added a commit that referenced this pull request Nov 20, 2026
robot-ch-test-poll added a commit that referenced this pull request Nov 20, 2026
Cherry pick #131731 to 26.8: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
robot-clickhouse added a commit that referenced this pull request Nov 20, 2026
robot-ch-test-poll added a commit that referenced this pull request Nov 20, 2026
Cherry pick #131731 to 26.9: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
robot-clickhouse added a commit that referenced this pull request Nov 20, 2026
robot-ch-test-poll added a commit that referenced this pull request Nov 20, 2026
Cherry pick #131731 to 26.10: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
robot-clickhouse added a commit that referenced this pull request Nov 20, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 20, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #131731 to 26.10: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #131731 to 26.9: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #131731 to 26.8: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
alexey-milovidov added a commit that referenced this pull request Nov 20, 2026
Backport #131731 to 26.3: Ignore publisher confirms with an unknown delivery tag in `RabbitMQProducer`
antaljanosbenjamin added a commit that referenced this pull request Nov 24, 2026
The backport of #127611 moved the publisher confirms state (`delivery_record`,
`returned`, `removeRecord`) from `RabbitMQProducer` to `RabbitMQPublisher`.
The unit test from the backport of #131731 still constructed
`RabbitMQProducer` and used these members, so `unit_tests_dbms` did not
compile in the debug, sanitizer and `arm_darwin` builds.

Test `RabbitMQPublisher` directly, as on master after #131731: the test is
`RabbitMQPublisherTest` in `gtest_rabbitmq_publisher.cpp`, and the `friend`
declaration moves from `RabbitMQProducer` to `RabbitMQPublisher`. The test
cases do not change.

#134083
antaljanosbenjamin added a commit that referenced this pull request Nov 24, 2026
The backport of #127611 moved the publisher confirms state (`delivery_record`,
`returned`, `removeRecord`) from `RabbitMQProducer` to `RabbitMQPublisher`.
The unit test from the backport of #131731 still constructed
`RabbitMQProducer` and used these members, so `unit_tests_dbms` did not
compile in the debug, sanitizer and `arm_darwin` builds.

Test `RabbitMQPublisher` directly, as on master after #131731: the test is
`RabbitMQPublisherTest` in `gtest_rabbitmq_publisher.cpp`, and the `friend`
declaration moves from `RabbitMQProducer` to `RabbitMQPublisher`. The test
cases do not change.

#134084
antaljanosbenjamin added a commit that referenced this pull request Nov 24, 2026
The backport of #127611 moved the publisher confirms state (`delivery_record`,
`returned`, `removeRecord`) from `RabbitMQProducer` to `RabbitMQPublisher`.
The unit test from the backport of #131731 still constructed
`RabbitMQProducer` and used these members, so `unit_tests_dbms` did not
compile in the debug, sanitizer and `arm_darwin` builds.

Test `RabbitMQPublisher` directly, as on master after #131731: the test is
`RabbitMQPublisherTest` in `gtest_rabbitmq_publisher.cpp`, and the `friend`
declaration moves from `RabbitMQProducer` to `RabbitMQPublisher`. The test
cases do not change.

#134085
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-message-queues Message queue integrations (Kafka, RabbitMQ, NATS table engines for stream ingestion/egress). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix 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.

3 participants