Skip to content

Conversation

@praboud
Copy link

@praboud praboud commented Oct 18, 2025

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

ClusterPipeline doesn't correctly handle returning connections to the connection pools.

  1. It's possible to leak connections if an error other than ConnectionError or TimeoutError is thrown when establishing connections. We only catch those specific errors (and the try/catch doesn't wrap the entire area where we're getting the connections); if others are thrown, the exception is simply raised to the caller, and the connections are never returned to their respective pools.
  2. More problematically, it's possible to return dirty connections to the pool if an error is thrown after at least one of the connections has been written to, and before all of the connections were read from. This can cause pretty bad correctness issues, where the client gets a response intended for a different request.

This diff addresses these issues by wrapping the entire area in a try/catch with a finally that ensures the connections are released, but which closes the connections if we have read but not written to the connection.

# we figure out the slot number that command maps to, then from
# the slot determine the node.
for c in attempt:
while True:
Copy link
Author

Choose a reason for hiding this comment

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

Unless I've completely lost the plot, this used to be a while True loop which always breaks on the first iteration, so this does ~nothing.

@petyaslavova
Copy link
Collaborator

Hi @praboud, thank you for your contribution! We will review your changes soon.

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.

2 participants