-
Notifications
You must be signed in to change notification settings - Fork 1
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
Close connections in datasources #397
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #397 +/- ##
==========================================
+ Coverage 87.97% 88.00% +0.02%
==========================================
Files 26 26
Lines 1031 1050 +19
==========================================
+ Hits 907 924 +17
- Misses 124 126 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
execution_engine = datasource.get_execution_engine() | ||
if isinstance(execution_engine, SqlAlchemyExecutionEngine): | ||
execution_engine.close() |
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.
This won't be enough to close all the sqlalchemy engine connections.
Some of our datasource use 2 different sqlalchemy engine instances.
Lets chat about this soon, but I think we need to add a datasource.close_connection()
/datasource.shutdown_connection()
method to the Datasource
interface in OSS and let each datasource implement the respective close connection operation.
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.
Oh interesting. By two different engine instances do you mean the _engine_backup
in the execution engine?
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.
No, but I'm not familiar with _engine_backup
; there could be an issue there too 😄 .
See the description of this abandoned PR.
But TLDR the SQLALchemy engine
used in datasource.test_connection()
is not the same engine used by the SQLAlchemyExecutionEngine
.
As described 👇 this has been fixed for SnowflakeDatasource, but it's still a problem for Postgres
, DatabricksSQL
and every other SQL datasource.
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.
Oh interesting. I did not know about the duplicate engine issue.
I also am realizing now that I missed that execution_engine.close()
does not close the actual connection if the _engine_backup
doesn't exist. I'm going to modify this PR to also explicitly call close on the connection just to test if it helps, but it sounds like we have more work to do overall.
No description provided.