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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
## dbt 0.17.2 (Release TBD)


### Breaking changes (for plugins)
- The `release` argument to adapter.execute_macro no longer has any effect. It will be removed in a future release of dbt (likely 0.18.0) ([#2650](https://github.com/fishtown-analytics/dbt/pull/2650))


### Fixes
- fast-fail option with adapters that don't support cancelling queries will now passthrough the original error messages ([#2644](https://github.com/fishtown-analytics/dbt/issues/2644), [#2646](https://github.com/fishtown-analytics/dbt/pull/2646))
- `dbt clean` no longer requires a profile ([#2620](https://github.com/fishtown-analytics/dbt/issues/2620), [#2649](https://github.com/fishtown-analytics/dbt/pull/2649))
- Close all connections so snowflake's keepalive thread will exit. ([#2645](https://github.com/fishtown-analytics/dbt/issues/2645), [#2650](https://github.com/fishtown-analytics/dbt/pull/2650))

Contributors:
- [@joshpeng-quibi](https://github.com/joshpeng-quibi) ([#2646](https://github.com/fishtown-analytics/dbt/pull/2646))


## dbt 0.17.2b1 (July 21, 2020)


Expand Down
12 changes: 4 additions & 8 deletions core/dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

👍

"""
if release is not False:
deprecations.warn('execute-macro-release')
if kwargs is None:
kwargs = {}
if context_override is None:
Expand Down Expand Up @@ -971,11 +973,7 @@ def execute_macro(
macro_function = MacroGenerator(macro, macro_context)

with self.connections.exception_handler(f'macro {macro_name}'):
try:
result = macro_function(**kwargs)
finally:
if release:
self.release_connection()
result = macro_function(**kwargs)
return result

@classmethod
Expand Down Expand Up @@ -1007,7 +1005,6 @@ def _get_one_catalog(
table = self.execute_macro(
GET_CATALOG_MACRO_NAME,
kwargs=kwargs,
release=False,
# pass in the full manifest so we get any local project
# overrides
manifest=manifest,
Expand Down Expand Up @@ -1063,7 +1060,6 @@ def calculate_freshness(
table = self.execute_macro(
FRESHNESS_MACRO_NAME,
kwargs=kwargs,
release=False,
manifest=manifest
)
# now we have a 1-row table of the maximum `loaded_at_field` value and
Expand Down
10 changes: 10 additions & 0 deletions core/dbt/deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class DbtProjectYamlDeprecation(DBTDeprecation):
'''


class ExecuteMacrosReleaseDeprecation(DBTDeprecation):
_name = 'execute-macro-release'
_description = '''\
The "release" argument to execute_macro is now ignored, and will be removed
in a future relase of dbt. At that time, providing a `release` argument
will result in an error.
'''


_adapter_renamed_description = """\
The adapter function `adapter.{old_name}` is deprecated and will be removed in
a future release of dbt. Please use `adapter.{new_name}` instead.
Expand Down Expand Up @@ -151,6 +160,7 @@ def warn(name, *args, **kwargs):
ColumnQuotingDeprecation(),
ModelsKeyNonModelDeprecation(),
DbtProjectYamlDeprecation(),
ExecuteMacrosReleaseDeprecation(),
]

deprecations: Dict[str, DBTDeprecation] = {
Expand Down
9 changes: 4 additions & 5 deletions test/rpc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ def pytest_collection_modifyitems(config, items):


def pytest_configure(config):
config.addinivalue_line('markers', 'supported(: Marks postgres-only tests')
# the '(plugin, ...)' part isn't really important: any positional arguments
# to `pytest.mark.supported` will be consumed as plugin names.
helptxt = 'Marks supported test types ("postgres", "snowflake", "any")'
config.addinivalue_line(
'markers', 'snowflake: Mark snowflake-only tests'
)
config.addinivalue_line(
'markers', 'any: Mark '
'markers', f'supported(plugin, ...): {helptxt}'
)


Expand Down