Skip to content

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.

@long2ice long2ice force-pushed the dev branch 3 times, most recently from a036841 to 6c16f3b Compare December 12, 2024 14:07
elbaro added a commit to elbaro/asyncmy that referenced this pull request Aug 2, 2025
@StrayDragon
Copy link

Cool, we need this fix, could you please prioritize it? I have to use a forked version now cannot receive update friendly ...

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

Labels

None yet

Projects

None yet

3 participants