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

Timeout BQ queries #902

Merged
merged 25 commits into from
Sep 11, 2023
Merged

Timeout BQ queries #902

merged 25 commits into from
Sep 11, 2023

Conversation

colin-rogers-dbt
Copy link
Contributor

@colin-rogers-dbt colin-rogers-dbt commented Aug 28, 2023

Time out and cancel a model execution if it exceeds the provided number of seconds.

Currently the bigquery python client does not provide us with a mechanism to specify a timeout on the database side. As a workaround until they do we can do the next best thing: timeout the execution, cancel the query and raise an exception.

Note we will only use this new logic if a user specifies the job_execution_timeout parameter in their profile. If it is not set we continue using the same behavior as today.

resolves #231
docs dbt-labs/docs.getdbt.com/#

Problem

Solution

Checklist

  • I have read the contributing guide and understand what's expected of me
  • 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
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@cla-bot cla-bot bot added the cla:yes label Aug 28, 2023
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-bigquery contributing guide.

@github-christophe-oudar
Copy link
Contributor

It's on my wishlist for dbt features!
I though about parsing dbt logs to cancel BQ jobs (parsing the URLs) at scheduler level but if it can support canceling queries on SIGTERM signals, it would be great 🙌
Thank you for working on this!

@colin-rogers-dbt
Copy link
Contributor Author

colin-rogers-dbt commented Aug 29, 2023

if it can support canceling queries on SIGTERM signals, it would be great

@github-christophe-oudar don't know if we'll tackle that in this pr as I think this calls for a consistent approach across adapters but I definitely want to tackle this

@colin-rogers-dbt colin-rogers-dbt marked this pull request as ready for review August 29, 2023 23:22
@colin-rogers-dbt colin-rogers-dbt requested a review from a team as a code owner August 29, 2023 23:22
@colin-rogers-dbt colin-rogers-dbt merged commit 2eb407d into main Sep 11, 2023
24 checks passed
@colin-rogers-dbt colin-rogers-dbt deleted the cancelJobQueriesDirectly branch September 11, 2023 18:12
github-actions bot pushed a commit that referenced this pull request Sep 15, 2023
* use dynamic schema in test_grant_access_to.py

* use dynamic schema in test_grant_access_to.py

* experiment with query job cancel on timeout

* modify unit tests

* remove test grants change

* starting functional test

* update functional test and experiment with polling logic

* experiment with async wait_for

* modifying connections.py for asyncio logic

* swap back to new_event_loop

* close loop, now seeing asyncio timeoutError

* improve order and update functional test

* update unit test

* add changie

* add max_result back to result call in async path

* rescope the dbt_profile_target to being a class fixture

* raise DbtRuntimeError instead database

* remove exception type check in job timeout

---------

Co-authored-by: Matthew McKnight <matthew.mcknight@dbtlabs.com>
Co-authored-by: Matthew McKnight <91097623+McKnight-42@users.noreply.github.com>
(cherry picked from commit 2eb407d)
mikealfare pushed a commit that referenced this pull request Sep 15, 2023
* use dynamic schema in test_grant_access_to.py
* experiment with query job cancel on timeout
* modify unit tests
* remove test grants change
* update functional test and experiment with polling logic
* experiment with async wait_for
* modifying connections.py for asyncio logic
* swap back to new_event_loop
* close loop, now seeing asyncio timeoutError
* improve order and update functional test
* add max_result back to result call in async path
* rescope the dbt_profile_target to being a class fixture
* raise DbtRuntimeError instead database
* remove exception type check in job timeout

---------

Co-authored-by: Matthew McKnight <matthew.mcknight@dbtlabs.com>
Co-authored-by: Matthew McKnight <91097623+McKnight-42@users.noreply.github.com>
(cherry picked from commit 2eb407d)

Co-authored-by: colin-rogers-dbt <111200756+colin-rogers-dbt@users.noreply.github.com>
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.

[CT-881] refactor retries
4 participants