nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
16k stars 1.41k forks source link

LeafNode: (no)interest propagation issues #6148

Open kozlovic opened 2 days ago

kozlovic commented 2 days ago

Observed behavior

Probably more cases than described here, but one would be that in a cluster hub/spoke setup, it was possible for interest registered in the leaf cluster to not be fully unregistered when the subscriptions were going away (depending if subscription was removed one by one or if a connection having multiple was closed), and more over, the hub may have incorrectly sent to the leaf cluster an interest on the subject, making publish from the leaf go to the hub where no interest was really present. This would happen if one of the hub server was restarted while subscription was still active, but then the subscriptions were removed.

Expected behavior

Subscription interest properly handled when subscriptions go away, either individually or as a whole when their connection is closed, or when servers are restarted.

Server and client version

Latest

Host environment

N/A

Steps to reproduce

    // B1 <--- route ---> B2
    //  |                 |
    // Leaf              Leaf
    //  |                 |
    // A1 <--- route ---> A2

Have queue subs connecting to A2, restart B1, unsubscribe one of the qsub from A2. When that happens, B1 may have sent a subscription interest to A1 (A1's Leafz would show a subscription interest). Removing the remaining subscriptions would not remove the subscription interest from A1->B1. Test can be repeated where a single connection has all 3 subs and connection is closed.