Repository navigation
fix(binding-mqtt): send retained messages for retain handling 1 only on a new subscription - #3160
Merged
Merged
Conversation
…subscription Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoY353ZpHcxZr2Kv8dD
… when re-subscribing a filter Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoY353ZpHcxZr2Kv8dD
…on a new subscription Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoY353ZpHcxZr2Kv8dD
jfallows
force-pushed
the
fix/3151-mqtt-retain-handling-1
branch
from
November 12, 2026 22:34
03d1687 to
8aeb940
Compare
jfallows
changed the base branch from
fix/3133-mqtt-v4-clean-session-persistence
to
develop
November 12, 2026 22:34
jfallows
marked this pull request as draft
November 12, 2026 22:58
jfallows
marked this pull request as ready for review
November 12, 2026 22:58
This was referenced Nov 12, 2026
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
MQTT 5.0 [MQTT-3.3.1-10]: with Retain Handling 1 the server MUST send retained messages matching the filter if the subscription did not already exist, and MUST NOT send them if it did.
MqttServerFactoryset the send-retained flag only for Retain Handling 0, so value 1 behaved like 2 and never replayed.Retain Handling 1 now carries
SEND_RETAINEDon the subscription (the same flag already carried in the session state and the subscribe begin/flush filters for value 0) only when the filter is not already among the session's subscriptions before this SUBSCRIBE. The production change is only incalculateSubscribeFlags. Retain Handling 0 and 2 handling is untouched, value 3 is still a protocol error, and MQTT 3.1.1 is unchanged. No Kafka-side change.Based on
develop.Test evidence (test-first)
New v5 network and application script pairs, each with spec-level IT methods and
server.v5.SubscribeITmethods:subscribe.retain.handling.1.new.filtersubscribe.retain.handling.1.existing.filtersubscribe.retain.handling.0.existing.filterRetain Handling 2 is already covered by
subscribe.qos0.publish.retained.no.replay.What failed first, run on the production code from before the fix with the final (corrected) scripts:
shouldSubscribeRetainHandling1NewFilterfailed because of the production code: Retain Handling 1 on a new filter did not setSEND_RETAINED.shouldSubscribeRetainHandling0ExistingFilteralso failed, but only through its first step. That script's first SUBSCRIBE uses Retain Handling 1 on a new filter, so it hits the same production defect. The Retain Handling 0 re-subscribe step itself needed no production change; Retain Handling 0 behavior is unchanged.shouldSubscribeRetainHandling1ExistingFilterpassed before the fix and stays as a regression guard that a re-subscribed filter does not replay.Scripts corrected in the second test commit (
follow the flush on the existing subscribe stream when re-subscribing a filter): the twoexisting.filterapplication scripts. My first draft expected a second subscribe stream on a re-subscribe; the existing behavior is a FLUSH on the already open subscribe stream carrying all of its filters. This was a wrong script expectation, not a production defect. The new1.new.filterscripts and the network scripts were not changed by it.After the fix:
specs/binding-mqtt.specverify 75 unit + 458 IT, 0 failures;runtime/binding-mqttverify 379 ITs, 0 failures (skips were already skipped), with checkstyle and license on and none of these modules restored from the build cache.Not delivered / follow-ups
A filter repeated within one SUBSCRIBE, or re-subscribed before the earlier SUBSCRIBE is acknowledged, is judged against the acknowledged session subscriptions only.
Fixes #3151
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoY353ZpHcxZr2Kv8dD