Repository navigation
fix(binding-mqtt-kafka): resolve retained replay subscription ids per filter - #3182
Merged
jfallows merged 2 commits intoNov 13, 2026
Conversation
…ned replay with a shared identifier Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoTpNwUipH69JKLSfoQ
… filter Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoTpNwUipH69JKLSfoQ
jfallows
force-pushed
the
fix/3172-mqtt-kafka-retained-filter-flags
branch
from
November 13, 2026 01:49
de3f4d8 to
cb98b40
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The retained stream (the replay path) kept a de-duplicated list of subscription ids (
retainedSubscriptionIds) and indexed the Kafka filter bitmask of each record over that list. The bitmask is aligned with the Kafka filter order, one bit per filter, so the two disagree as soon as two filters share a subscription identifier, or the filters of an open retained stream change:sensor/one(id 1),sensor/two(id 1),sensor/three(id 2), all with Send Retained. The list is[1, 2]. A retained message matching onlysensor/two(bit 1) was delivered with subscription id 2 instead of 1, and one matching onlysensor/three(bit 2) was delivered with no subscription id.[one(1)]to[two(2), one(1)]left the list as[1, 2](it was only appended to), so a retained message matchingsensor/twowas delivered with id 1 instead of 2.The messages stream already resolves this correctly with one id and one flags entry per filter, aligned with the Kafka filter order. This change makes the retained stream use that same implementation instead of a copy: the per-filter id and flag lists and
buildSubscriptionIds(withmatchedSubscriptionId) move into the sharedKafkaProxybase class, and bothKafkaMessagesProxyandKafkaRetainedProxyuse them. The lists are rebuilt on every begin and every flush from the filter list sent to Kafka, as the messages stream does.retainedSubscriptionIdsis removed. Retained replay still always sets RETAIN, so Retain As Published and No Local do not change the replay flags; No Local is still applied as a Kafka filter condition throughbuildFilterConditions.Fixes #3172
Based on #3180's branch (
fix/3167-mqtt-kafka-subscribe-offset-maps, headad8f8dfcf), which is itself stacked onfix/3177-mqtt-per-filter-suback-failureanddevelop. Only my two commits sit on top of that head.MqttKafkaSubscribeFactory.javais identical between #3180's previous head (747ecdc34) and its current head, so the restack of this PR was a mechanical rebase with no edits. The base should be retargeted todevelopafter the PRs below it merge.MQTT specification
Read in full from the OASIS pages (v5.0 OS and v3.1.1 OS, tags stripped, then read as text). Quotes are from that text.
sensor/twocarries id 1, one matching onlysensor/threecarries id 2.Statements from #3161 and #3159 that I did not re-verify in this PR (Retain Handling, [MQTT-3.3.1-9] to [MQTT-3.3.1-11]) are not relied on here.
Test evidence
Test-first: the first commit holds the scripts and ITs only (
subscribe.retain.shared.subscription.idandsubscribe.filter.change.retain.reordered, mqtt and kafka sides, run byMqttIT,KafkaITandMqttKafkaSubscribeProxyIT). The peer-to-peer spec ITs pass, so the scripts agree with each other. Against #3180's unchangedMqttKafkaSubscribeFactory(ad8f8dfcf), bothMqttKafkaSubscribeProxyITmethods fail (2 failures, in the Data extension of the first delivered message: wrong subscription id). With the fix they pass.After the fix, every module run with
clean verify, checkstyle and license checks on, build cache skipped, upstream modules installed with-amfirst:specs/binding-mqtt-kafka.spec: 268 ITs, 0 failures (+ 27 unit tests)runtime/binding-mqtt-kafka: 152 ITs, 0 failures (+ 10 unit tests)Not run: other modules; the change is confined to
MqttKafkaSubscribeFactoryand its scripts. The known intermittentshouldReceiveServerSentRetainedResetfailure (see #3161) did not occur in this run.Not delivered / follow-ups
KafkaMessagesProxy.doKafkaFlushkeeps its own copy of the condition building, noted in fix(binding-mqtt-kafka): apply qos and no local conditions to retained replay on filter change #3159); not touched here.🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoTpNwUipH69JKLSfoQ