You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MQTT: replacing a durable SUBSCRIBE on a collection topic does not re-send retained messages #3543
When an MQTT client with a durable session (clean: false) sends a new SUBSCRIBE for a collection topic it is already subscribed to (an in-place replacement, retain handling 0), Harper continues the existing subscription's position but does not re-send the retained (current) records. MQTT v5 §3.3.1-9 and v3.1.1 §3.8.4-3 require matching retained messages to be sent on a replacing SUBSCRIBE with retain handling 0. Single-record topics are not affected.
Mechanism (harper c7feeffdb)
server/DurableSubscriptionsSession.tssubscribeTopic (~1186-1200) sets request.startTime = existing.entry.startTime whenever the topic already had a durable entry.
In resources/Table.tssubscribe, the collection branches if (startTime || resuming) (~7214, replay from the log) and else if (!request.omitCurrent) (~7338, retained scan) are mutually exclusive, so a replacement replays but never scans. The single-record path sends current state in a separate if (~7470), which is why it works.
Fix direction
On a replacement with !omitCurrent, the collection branch should both replay missed events from the held position and send the current records. DESIGN already accepts duplicates under retained-message semantics; the ordering against dropDuringReplay / pendingRealTimeQueue needs care. Open PR #3356 rewrites the replacement block in subscribeTopic, so sequence against it.
Lower-severity notes from the same investigation
Replacing a QoS 2 subscription with QoS 1 calls forgetTopic(replaced) (~928), which drops QoS 2 receipts while the replay restarts from the held position, so an already-completed delivery is re-sent as QoS 1 with DUP=0. Allowed by QoS 1 at-least-once; only the DUP bit is wrong.
After a replacement, replayed ALREADY_RECEIVED deliveries continue (~428-431) before needsAcknowledge, so deliveredKey stays unset and the saved position holds back until the next fresh delivery. Nothing is lost.
A regression test covering all of these exists and will ship with the fix.
Activity