-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add Query Cancellation #918
Conversation
This PR has been marked as Stale because it has been open with no activity as of late. If you would like the PR to remain open, please comment on the PR or else it will be closed in 7 days. |
Although we are closing this PR as stale, it can still be reopened to continue development. Just add a comment to notify the maintainers. |
Reopening this PR as supporting query cancelation would be valuable and bring dbt-bigquery inline with cancelation support in other adapters. Benefits of this feature are discussed here: #917
If this feature will be addressed by a different approach/PR please let me know and we can close this one. |
Thanks @d-cole - we can try taking another look here. The changes in this PR are fairly intricate, so it will require careful review, especially around how we want to functionally test this. |
closing in favor of #1251 |
resolves # #917
docs dbt-labs/docs.getdbt.com/# N/A
Problem
The BigQueryConnectionManager cannot cancel queries.
Solution
This PR adds query cancellation by:
_retry_and_handle
to call client.cancel_job.Why predetermine job_ids?
Initially I considered persisting job_ids after client.query is called. However, this could lead to a race condition if a job has been started and a termination is sent before the job_id was stored, leading to a failure to cancel the job. By predetermining job_ids (uuid4), we can persist the job_id before the job has been kicked off. Doing this, the race condition only leads to attempting to cancel a job that doesn't exist.
Alternatives considered:
I considered using sessions similar to the Snowflake adapter. This doesn't seem feasible as the python api currently does not support session termination.
Questions for reviewers:
Checklist