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

Fix: close connections after use #2650

Merged
merged 6 commits into from
Jul 28, 2020
Merged

Fix: close connections after use #2650

merged 6 commits into from
Jul 28, 2020

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented Jul 27, 2020

resolves #2645

Description

To make the snowflake thread exit, we need to actually close open connections. We should have been doing this before!

Fixing that caused some fallout with connection management, especially in single-threaded mode but also in a couple other places that were relying on open connections not being closed. I think this is all set now.

In order to test this, I had to modify the rpc integration tests to support snowflake. I think the way I did it is pretty good. Of note, I only enabled two snowflake tests (one snowflake-specific one) - the snowflake tests are just way too slow for us to reasonably run the full suite, IMO. Snowflake already takes an eternity.

I anticipate this will make it a bit easier to add RPC tests for other adapter-specific issues we find.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot cla-bot bot added the cla:yes label Jul 27, 2020
@beckjake beckjake force-pushed the fix/close-connections branch 2 times, most recently from 08802d8 to 3611f2d Compare July 27, 2020 21:15
Jacob Beck added 3 commits July 27, 2020 15:16
- close() implies rollback, so do not call it
- make sure to not open new connections for executors in single-threaded mode
- logging cleanups
- fix a test case that never acquired connections
- to cancel other connections, one must first acquire a connection for the master thread
- change a number of release() calls to rollback

release vs rollback
@beckjake beckjake force-pushed the fix/close-connections branch 2 times, most recently from 3101ef6 to 23ed2f5 Compare July 27, 2020 21:53
@beckjake beckjake marked this pull request as ready for review July 28, 2020 13:36
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

The two new Snowflake rpc tests look great. The rest of the code is a bit beyond me.

I think our next steps should be:

  • merge
  • cut 0.17.2-rc1
  • get it into dbt Cloud
  • confirm "run sql" hanging is resolved in the IDE

Does that sound good to you @beckjake @kwigley?

Copy link
Contributor

@kwigley kwigley left a comment

Choose a reason for hiding this comment

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

2 tiny things but this looks great

test/rpc/conftest.py Outdated Show resolved Hide resolved
@@ -1059,7 +1063,7 @@ def calculate_freshness(
table = self.execute_macro(
FRESHNESS_MACRO_NAME,
kwargs=kwargs,
release=True,
release=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

is the release arg used anymore and should it stick around if not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not used in core anymore, but it is used in some plugins. Maybe anything using it needs to be changed anyway, I just hate to cause more plugin churn.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it, sounds good

Copy link
Contributor Author

@beckjake beckjake Jul 28, 2020

Choose a reason for hiding this comment

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

I've played around with this some, and I think we have to remove the release arg.

@jtcohen6 I think this will break any dependent adapters. I am mostly fine with that happening in a patch release since it fixes a pretty crippling bug. Ours all are locked to minor versions so we'll be fine... let me know what you think!

edit: I've decided to deprecate it. I don't think it's a great fix, but I think it's an okay fix. Some adapters that are currently using the release argument may not have to make changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok! I'm on board. This is a tiny breaking change to resolve a much more significant regression. We'll want to check that our plugins (spark + presto) can work with 0.17.2-rc1.

 - fix conftest adainivalue_line calls
 - deprecate the release argument to execute_macro
@@ -934,8 +934,10 @@ def execute_macro(
execution context.
:param kwargs: An optional dict of keyword args used to pass to the
macro.
:param release: If True, release the connection after executing.
:param release: Ignored.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants