-
Notifications
You must be signed in to change notification settings - Fork 79
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
[Bug] Cancelling dbt invocation does not cancel the query on Athena #406
Comments
The adapter cancel behavior is defined here: dbt-adapters/dbt/adapters/base/impl.py Line 1327 in b6152d6
Then if we go to the SQLConnectionsManager, the
But in the AthenaConnectionsManager, we don't implement the cancel method: https://github.com/dbt-labs/dbt-athena/blob/8e2aa424256e354103d619cc07f9a79d85fadf98/dbt-athena/src/dbt/adapters/athena/connections.py#L321-L322 The |
After deep-diving the code I think I found the issue. The cancel query happens here: https://github.com/dbt-labs/dbt-core/blob/3de3b827bfffdc43845780f484d4d53011f20a37/core/dbt/task/runnable.py#L429-L448 As it should be, the raise of the exception is done after the cancel of the queries is done. Therefore, I think implemented the cancel method will fix the error. But I also think the _poll method is not working as expected (https://github.com/dbt-labs/dbt-adapters/blob/main/dbt-athena/src/dbt/adapters/athena/connections.py#L128-L138). |
We had a similar scenario in dbt-adapters/dbt-bigquery/src/dbt/adapters/bigquery/connections.py Lines 131 to 151 in 014d5f9
|
👋🏻 Hello Thanks @mikealfare for your message. It helped a lot. I deep dived a little bit the big query client implementation and I think closing all cursors on a connection close, as it is done on the BQ client should fix the issue. I am a little bit curious now on why this is not enough on the big query adapter to just call the cancel method of the Connection? I opened an issue on PyAthena: laughingman7743/PyAthena#575 |
Hum after checking the owner of PyAthena, python-bigquery client does not cancel the query on cancelling the cursor (it just marks the cursor as closed). Now I understand why there is a need to keep track of the job ids. I have to check if we could replicate this by retrieving the query execution id |
The main issue is that:
So a solution would be to store at some point the current cursor used and to cancel it if we call the cancel method. |
👋🏻 Hello dbt-athena community,
Is this a new bug in dbt-athena?
Current Behavior
When I try to cancel a dbt invocation, the invocation can be cancelled but the query is not cancelled in Athena. Therefore it can lead to concurrent requests when retrying.
Expected Behavior
When the dbt invocation cancel process is done, the query should be cancelled in Athena
Steps To Reproduce
Relevant log output
No response
Environment
Additional Context
No response
The text was updated successfully, but these errors were encountered: