Status: accepted Date: 2026-10-08 Deciders: GoBridge core Amends: 0022 (retained messages are no longer replayed on a reconnect the broker resumed; this adds one protocol version check above the translator) Relates to: 0003 (the reconcile and the managed-subscription history that act on the kept subscriptions), 0021 (a settlement recovery reconnects through Reload, which this keeps resumable)
Every connection-up empties the session’s record of the subscriptions the
broker confirmed (observedSubs, activeSubs), and the reconcile the runtime
runs next SUBSCRIBEs every filter of the plan again. On MQTT 5 that costs
nothing: a Persistent or Exclusive session’s SUBSCRIBE carries Retain Handling
1, so the broker sends retained messages only for a subscription that did not
exist yet.
MQTT 3.1.1 has no Retain Handling. Every SUBSCRIBE makes the broker send the filter’s retained messages again (MQTT 3.1.1 §3.8.4), so a 3.1.1 session got every matching retained message again on every reconnect.
A CONNACK with Session Present set means the broker kept the session (§3.2.2.2), and the session state includes the client’s subscriptions (§3.1.2.4). After such a CONNACK the broker still holds every subscription the previous connection had confirmed.
On MQTT 3.1.1, a connection-up whose CONNACK has Session Present set keeps the broker-confirmed subscription record of the connection before it, when the session is Persistent or Exclusive and all its broker URLs reach one canonical endpoint. The reconcile that follows then SUBSCRIBEs only filters that are new or whose requested QoS changed, and UNSUBSCRIBEs removed ones. An unchanged filter gets no SUBSCRIBE, so the broker replays nothing for it.
It is a plain branch on the protocol version in
handleConnectionUpGenerationWithSessionPresent; keepResumedSubscriptionsLocked
and resetSubscriptionRecordLocked in session_resume.go do the work. Every
other connection-up resets the record exactly as before: MQTT 5, Session
Present not set, and Ephemeral sessions.
Everything else on connection-up is unchanged: subscriptionsSatisfied is
false until the reconcile converges the plan, the connection epoch advances,
the unmatched grace window restarts, resume-loss detection runs, and the
QoS-downgrade records stay as they are.
Two kinds of filter are dropped from a kept record, so the reconcile treats them as after a fresh session:
unackedSubs). A connection that drops in the middle of
the round trip leaves the broker’s state for that filter unknown. Keeping
its record could skip the SUBSCRIBE of a filter the broker already removed,
which would lose it silently, or of one the broker now holds at another QoS.
A path that can change a filter recorded at full grant (the reconcile
SUBSCRIBE and unsubscribeConfirmed, which the managed cleanup uses) marks
it before sending. A mark is cleared only where the acknowledgement is
recorded on the same connection: applyGrantLocked and
removeObservedSubscriptions. The QoS probe and the orphan cleanup do not
mark: the probe re-subscribes only filters granted below their requested
QoS, and the orphan cleanup unsubscribes only a topic that is not active, so
a resumed connection never keeps either record.The record assumes that only this session changed the broker session’s subscriptions. It is dropped wherever the session gives the broker session up, because another owner of the client id may then change them:
disconnectGeneration always resets it, on every protocol version. A failed
exclusive reconcile calls it and then releases the lease; the terminal
transition calls it too.A Reload that succeeds keeps the session’s ownership: a credential rotation that needs a new connection, a managed-subscription cleanup, a settlement recovery. On MQTT 3.1.1 it no longer resets the record at teardown, and leaves the choice to the replacement’s connection-up. MQTT 5 still resets at teardown.
Session Present from another broker would describe that broker’s session.
ValidateSessionMode already refuses a Persistent or Exclusive session whose
broker URLs reach more than one canonical endpoint. A session built directly
with NewSession is not validated that way, so it checks the same condition at
construction (oneBrokerDomain). An Ephemeral session connects with Clean
Session set on every connect, so the broker never resumes it.
mqtt.retained=true:
MQTTSessionResumeLost counts a loss);subscriptionsSatisfied stays false, so the session cannot report
Full before the reconcile converges.TestIntegration_MQTT311_ResumedSessionDoesNotReplayRetained).client_id, or use an exclusive lease.