Skip to content

Prevent duplicate subscription ID's in destinationCache of DefaultSubscriptionRegistry #32625

@heowc

Description

@heowc

Affects: 6.1.5


hello.

I encountered a problem with multiple subscriptions while delivering broadcast messages to subscribed sessions (clients), and I thought there might be a need for a way to prevent this, so I created an issue thinking it would be good to discuss.

My case is as follows:

  1. For some reason, subscription request was made twice for subscription A with the same ID (sub-1).
  2. The server stores it in memory as shown below.
    • sessionRegistry is {session-id, sub-1, subscription}
    • desctinationCache is {A, session-id, {sub-1,sub-1}}
  3. If you cancel subscription A
    • Find session information by session-id in sessionRegistry and remove subscription by sub-1
    • Get a list of all session-ids corresponding to desctination from desctinationCache and remove only one identical subscription ID from it.

In the above situation, sub-1, which cannot be erased, remains in desctinationCache. Of course, the client implementation may be incorrect, but it seems that this could lead to a situation in which excessive memory may accumulate on the server.

To think briefly, I think it would be a good idea to store the subscription list in desctinationCache as a collection that does not allow duplication, such as a hashset, rather than an array list. Or is there a reason it has to be this way or is there another better way?

I see a few similar issues, but they seem slightly different.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions