Skip to content

Pub/sub: keep client and server subscription state in step around unsubscribe - #3377

Draft
mgravell wants to merge 2 commits into
mainfrom
marc/pubsub-retiring
Draft

mgravell wants to merge 2 commits into
mainfrom
marc/pubsub-retiring

Conversation

@mgravell

Copy link
Copy Markdown
Member

Work in progress for #3375. Draft: more commits to come.

So far

Restores skip a subscription that is being retired. Since #3363, a subscription whose last handler has been removed stays in the multiplexer until its unsubscribe has been issued. A reconnect or reconfigure in that window could subscribe it again, and nothing would then unsubscribe it, because the client forgets it straight after. The ensure paths (single-node and multi-node, sync and async) now do nothing for a retired subscription.

Test: RestoreDoesNotResubscribeARetiredSubscription (literal, pattern and multi-node channels; sync and async). All six cases fail without the change.

This narrows the window and does not close it: a restore that reads "not retired" just before the unsubscribe retires the subscription can still send its subscribe afterwards. That is covered by the ack-time work below.

Still to do

mgravell and others added 2 commits November 24, 2026 10:23
A retired subscription stays in the multiplexer until its unsubscribe has been
issued (#3363), so a reconnect or reconfigure in that window could subscribe it
again; nothing would then unsubscribe it, because the client forgets it straight
after. The ensure paths now do nothing for a retired subscription.

This narrows the window rather than closing it: a restore that reads 'not
retired' just before the unsubscribe retires it can still send its subscribe
afterwards. See #3375.
…is unsubscribed

An unsubscribe that lands while the subscribe is still unacknowledged has no
server to send anything to, because the server is only recorded when the
acknowledgement arrives. The acknowledgement was then adopted by a subscription
the client had already forgotten, and the server stayed subscribed (#3375).

The acknowledgement is now treated as a stray when the subscription is retired,
and the registration it confirms is removed. Exactly one side owns that removal:
retiring takes the recorded server(s) after marking the subscription retired, an
acknowledgement records its server before checking for retirement, and whichever
takes the server back out sends the unsubscribe.

If the channel has been subscribed afresh in the meantime, the stray is only
removed when the newer subscription is known to be on another server; an
unsubscribe that followed the newer subscribe onto the same server would
silently stop its messages.

Tests adapted from #3337.

Co-authored-by: vkyow <218959617+vkyow@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant