Skip to content

Pub/sub: a multi-node subscription forgets its disconnected nodes, not its connected ones - #3374

Merged
mgravell merged 1 commit into
mainfrom
marc/multinode-remove-disconnected
Nov 23, 2026
Merged

mgravell merged 1 commit into
mainfrom
marc/multinode-remove-disconnected

Conversation

@mgravell

Copy link
Copy Markdown
Member

MultiNodeSubscription.RemoveDisconnectedEndpoints had its condition inverted: it flagged the connected nodes for removal and kept the disconnected ones. The single-node flavour has always had it the right way round.

ServerEndPoint.OnDisconnected calls this (via UpdateSubscriptions) whenever any subscription connection drops, so for a keyspace-notification subscription on a cluster, one node dropping meant:

  • every healthy node was dropped from the subscription's tracking, while the dead one stayed;
  • ISubscriber.IsConnected(channel) reported false although the healthy nodes were still subscribed and delivering;
  • an unsubscribe before the next restore pass never reached the healthy nodes, because unsubscribe only walks the tracked nodes, so they stayed subscribed on the server.

The next restore re-adds the healthy nodes (a redundant PSUBSCRIBE each), which is why this has mostly gone unnoticed.

Change

One character: if (server.Value.IsSubscriberConnected) becomes if (!server.Value.IsSubscriberConnected).

This hunk is also in #3353; splitting it out here so it can be reviewed and tested on its own. #3353 should drop it once this lands.

Test

MultiNodeSubscriptionTrackingTests (in-process server, no external Redis): subscribes to a keyspace channel, adds a tracked-but-disconnected node, runs UpdateSubscriptions, and asserts the connected node is still tracked and the dead one is gone. It fails on main (the connected node is no longer tracked) and passes with the fix.

…t its connected ones

MultiNodeSubscription.RemoveDisconnectedEndpoints had its test inverted: when any subscription connection dropped, a keyspace-notification subscription dropped every *connected* node from its tracking and kept the dead one. The healthy nodes then reported as not subscribed (ISubscriber.IsConnected returned false) and, because unsubscribe only walks the tracked nodes, an unsubscribe before the next restore never reached them, leaving them subscribed on the server.

The single-node flavour has always had the condition the right way round.
@mgravell
mgravell merged commit 2d3000c into main Nov 23, 2026
6 of 7 checks passed
@mgravell
mgravell deleted the marc/multinode-remove-disconnected branch November 23, 2026 16:21
mgravell added a commit that referenced this pull request Nov 23, 2026
…ptEndpoint (#3376)

#3374 added a test calling Subscription.AddEndpoint; #3353 renamed that to
TryAdoptEndpoint. Each was green alone and they merged without a textual
conflict, but main does not compile with both.
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