Skip to content

Topic exchanges: limit the number of multi-segment matchers allowed - #17039

Merged
michaelklishin merged 1 commit into
mainfrom
mk-item-22cq
Jul 28, 2026
Merged

michaelklishin merged 1 commit into
mainfrom
mk-item-22cq

Conversation

@michaelklishin

Copy link
Copy Markdown
Collaborator

This PR has two parts.

Restriction of Multi-Segment Matchers

Having multiple # segments is usually not necessary and results
in higher resource use for no real benefit.

MQTTv5 restricts patterns to one such matcher.
This PR caps the count at two to accommodate for
certain exotic but still realistic use cases.

Trie Matching Refactoring

This PR also introduces a memoization (caching) in
a trie matching function, further reducing the computational cost of using
up to two multi-segment matchers #.

Other

Per discussion with @ansd @dcorbacho.

@mergify

mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@mergify mergify Bot added the make label Jul 28, 2026
@michaelklishin michaelklishin changed the title Topic exchanges: limit the number of multi-segment matchers Topic exchanges: limit the number of multi-segment matchers allowed Jul 28, 2026
Having multiple `#` segments is usually not necessary
and results in higher resource use for no real benefit.

MQTTv5 restricts patterns to one such matcher.
This PR caps the count at two to accommodate for
certain exotic but still realistic use cases.

Per discussion with @ansd @dcorbacho.
@michaelklishin
michaelklishin merged commit 50fe1ec into main Jul 28, 2026
186 checks passed
@michaelklishin
michaelklishin deleted the mk-item-22cq branch July 28, 2026 04:27
michaelklishin added a commit that referenced this pull request Jul 28, 2026
michaelklishin added a commit that referenced this pull request Jul 28, 2026
Topic exchanges: limit the number of multi-segment matchers allowed (backport #17039)
@splatteredbits

Copy link
Copy Markdown

This is a breaking change and should have been queued to a major version of RabbitMQ. We have 10 routing keys that use three or more # characters. How does this impact existing routing keys? Is there a way to turn off this behavior?

@michaelklishin

michaelklishin commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

@splatteredbits that's a security fix, so you are welcome. There is no justification for using three or four multi-segment # patterns.

@rabbitmq rabbitmq locked and limited conversation to collaborators Nov 2, 2026
@michaelklishin

michaelklishin commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Is there a way to turn off this behavior?

There is no. Multiple # segments are unnecessary (they match multiple segments and are used for the "tail part" of a pattern). We support two for what I mention as "exotic use cases" above.

There is no limit on how many single segment matchers, *, there can be.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants