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

dbt rpc's "run_sql" method can hang forever #2645

Closed
1 of 5 tasks
beckjake opened this issue Jul 24, 2020 · 1 comment
Closed
1 of 5 tasks

dbt rpc's "run_sql" method can hang forever #2645

beckjake opened this issue Jul 24, 2020 · 1 comment
Labels
bug Something isn't working rpc Issues related to dbt's RPC server
Milestone

Comments

@beckjake
Copy link
Contributor

Describe the bug

Given a snowflake environment with client_session_keepalive set to True, the run_sql RPC call will successfully run and then never finish. This manifests as the rpc poll call showing the task as still running, forever.

The process will show up in the process table and the RPC server's ps output as being active on the OS level, but it won't be actually doing anything. In particular it'll be blocking on join()ing the process.

The problem here is that the background thread that the snowflake connector starts is hanging, because dbt never calls close() on the handle. The fix is to update dbt.adapters.base.connections.ConnectionManager.release() to always call close(), even when the connection state is "open" (currently it only calls it if the state is not "open", which seems pretty silly).

Steps To Reproduce

  • set up a profile with client_session_keepalive: true
  • run dbt rpc and point it at that profile
  • call run_sql with select 1 as id as the argument, or anything else you like
  • wait forever

Expected behavior

The API call should return pretty much immediately.

Screenshots and log output

N/A

System information

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:
dbt==0.17.1

The operating system you're using:
macos or linux

The output of python --version:
Any? 3.6 and 3.8 both have it.

Additional context

I was able to reproduce this behavior on macos with dbt 0.17.0, but not on Linux, so I assume it has to do with some oddity of spawn vs fork behavior.

@beckjake beckjake added bug Something isn't working triage labels Jul 24, 2020
@jtcohen6 jtcohen6 removed the triage label Jul 24, 2020
@jtcohen6 jtcohen6 added this to the 0.17.2 milestone Jul 24, 2020
@jtcohen6
Copy link
Contributor

Resolved by #2650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rpc Issues related to dbt's RPC server
Projects
None yet
Development

No branches or pull requests

2 participants