villebro opened a new pull request, #22498:
URL: https://github.com/apache/superset/pull/22498

   ### SUMMARY
   Currently cancelling queries on Trino fails if the query cancellation 
request has been submitted before the query id has been retrieved. This 
typically happens when executing using async query execution, as the query 
first gets placed on the Celery queue prior to being executed. To work around 
this, we add a new method `prepare_cancel_query` on `BaseEngineSpec` which is 
called when calling the query cancellation endpoint. On Trino this will set an 
"early query cancellation" flag to `True`, which will trigger the query to 
cancel when the `BaseEngineSpec.handle_cursor` is called during query 
execution. Appropriate tests are also added.
   
   ### AFTER
   Now stopping a query immediately shows the correct alert for both sync and 
async modes:
   
   
https://user-images.githubusercontent.com/33317356/208901143-bf41975a-24d4-476b-8ede-1a2ba3ccb03e.mp4
   
   ### BEFORE
   
   
https://user-images.githubusercontent.com/33317356/208901234-183a11ee-51c8-4730-a2eb-25c845b476d9.mp4
   
   In addition, when running queries in sync mode, cancelling a query would 
sometimes flash the following error:
   
   
![image](https://user-images.githubusercontent.com/33317356/208893540-a2d5a3c9-6e69-489e-9dd4-069149d6eb38.png)
   
   This was due to the result handler not considering the possibility of the 
query being returned in a stopped state. To fix this, the query result handling 
logic is changed to only trigger if the result is successful. 
   
   ### TESTING INSTRUCTIONS
   1. Connect to a Trino database
   2. Execute a long running query and immediately cancel it
   3. Wait for an error to show up complaining about the query failing to stop.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to