-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PgListener getting messages from channels it's not subscribed to #612
Comments
Can you try making We may be getting a "used" connection that already had |
Hi thanks for the reply. After some more testing, I think that that is exactly the issue. Moreso, I think that connections in the pool aren't unsubscribing properly once the listener is dropped. I am using a low number of connections (8 specifically) and 'not happening consistently' is really more like 'absolutely happening consistently' as the probability of getting an already-listening connection goes up. Creating a new pool each time sidesteps the issue. |
So |
I had considered doing that but it's not clear how to fire off an async task in the drop method without blocking. Spawning a task requires we block until the task is executed otherwise the future outlives the |
In the meantime, we could do something like this: struct PgListener(Option<InternalPgListener>);
impl Drop for PgListener {
fn drop(&mut self) {
let listener = self.0.take();
tokio::spawn(listener.async_drop());
}
} |
Something that would not necessarily be an optimal fix but would address the issue is to just close the connection on-drop. If the connection is part of a pool it'll allow a task waiting on |
Another suggestion: Could this be solved by using one of the hooks in |
Something along the same lines as @NyxCode's suggestion above is to have the connection notify the pool that the unsub needs to take place if it is dropped while subscribed, and then the pool may unsubscribe when that connection is aquired by something else. |
A simple fix actually would be to just push a |
I have a graphql endpoint with a subscription:
When a subscription request is created, a listener is created from the pool, listening to events on
id
channel. Interestingly, in some cases, a listener can accidentally receive events from a channel it's not subscribed to:It doesn't happen consistently, and I wish I could provide some more details. Is there anything that jumps out as immediately suspicious?
The text was updated successfully, but these errors were encountered: