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

handle connection close on CancelledError to prevent stale results #108

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

shenchucheng
Copy link

Description

This PR resolves an issue where canceled queries using connections from a pool leave unintended results that affect subsequent queries. When a query is canceled, the connection is returned to the pool without proper cleanup, causing future queries to receive residual data from the canceled task.

Solution

  • Implemented _close_on_cancel to ensure that connections are fully closed and reset when a query is canceled.
  • Added a test case to verify that canceled queries do not impact future connections from the pool.

This update ensures clean connection states on cancellation, improving reliability in pooled query operations. This approach is inspired by similar handling in aiomysql

Related Issues

@long2ice
Copy link
Owner

Please run make style ci in local first

@shenchucheng
Copy link
Author

Please run make style ci in local first

Okay, I've updated it. Please check again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment