-
Notifications
You must be signed in to change notification settings - Fork 169
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
Prevent error when closing an unused cursor #405
base: master
Are you sure you want to change the base?
Conversation
SQLAlchemy will attempt to close cursor objects even if, for whatever reason, they haven't actually been used and therefore have no associated query to cancel.
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks,
can you share some sequence of operations which leads this to happen? It'd be useful to have a regression test for this if possible.
Hi, this is slightly tricky to reproduce but I'm seeing it in the tracebacks from failures in CI when our test Trino instance goes down. It's something to do with SQLAlchemy's pool manager trying to close out connections after an error. Here's the key bit of the traceback:
And here's the full thing (click to expand)
|
Oh, interesting. Looking at the CI failures here there's an explicit test for the behaviour which my patch tries to remove: trino-python-client/tests/integration/test_dbapi_integration.py Lines 1343 to 1352 in f98a608
But I'm not sure that is the behaviour you actually want. The test was added in fca57d4 and looks like a direct copy-paste of the test for trino-python-client/tests/integration/test_dbapi_integration.py Lines 1331 to 1340 in f98a608
I think that explicitly calling |
In my head the logic should be:
We don't do steps 2 and 3 here (both required by DB-API).
|
@evansd Me and @hovaesco discussed this offline and we agree with the changes described in my previous comment. So can you please change
And add some tests to verify this new behavior. |
@evansd Any updates here? |
Not yet, I'm afraid. This isn't a blocking issue for us at the moment as we've worked around the problem we had of the Trino instance going down during CI runs, so the behaviour in question no longer gets triggered. I'm still planning to make the fix following the behaviour you've outlined; but we've got a lot of other high priority work on at the moment so it won't be for a few weeks. |
Thanks for the update @evansd. |
Some parts of this were addressed in #405 |
SQLAlchemy will attempt to close cursor objects even if, for whatever reason, they haven't actually been used and therefore have no associated query to cancel.
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(*) Release notes are required, with the following suggested text:
* Support cleanly closing unused cursor