Skip to content
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

fix(clustered pubsub): check that client.isOpen before calling client.disconnect() when unsubscribing #2687

Merged
merged 4 commits into from
Jan 29, 2024

Conversation

BrentLayne
Copy link
Contributor

@BrentLayne BrentLayne commented Jan 10, 2024

Description

This PR fixes this issue #2685 whereby concurrent requests to a redis cluster for any of UNSUBSCRIBE, PUNSUBSCRIBE, SSUBSCRIBE can result in ClientClosedError being thrown, due to a race condition between the concurrent requests to disconnect the socket.

It fixes the issue by checking if client.isOpen before calling client.disconnect() in executeShardedUnsubscribeCommand and executeUnsubscribeCommand

Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

@BrentLayne BrentLayne marked this pull request as ready for review January 10, 2024 15:21
@BrentLayne
Copy link
Contributor Author

I'm running into issues getting npm run build:test-tools to work, so I wasn't able to run the tests locally, but they are pretty simple tests so I expect they should pass in the CI workflow.

@BrentLayne BrentLayne changed the title (fix:cluster): check that client.isOpen before calling client.disconnect when unsubscribing fix(cluster): check that client.isOpen before calling client.disconnect when unsubscribing Jan 10, 2024
@BrentLayne BrentLayne changed the title fix(cluster): check that client.isOpen before calling client.disconnect when unsubscribing fix(clustered pubsub): check that client.isOpen before calling client.disconnect when unsubscribing Jan 10, 2024
@BrentLayne BrentLayne changed the title fix(clustered pubsub): check that client.isOpen before calling client.disconnect when unsubscribing fix(clustered pubsub): check that client.isOpen before calling client.disconnect() when unsubscribing Jan 10, 2024
Copy link
Collaborator

@leibale leibale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks! :)

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.

Concurrent requests to SUNSUBCRIBE causes a race condition bug (ClientClosedError)
2 participants