You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/05/29 17:22:30 UTC

[GitHub] [incubator-superset] smacker opened a new pull request #7611: [sqllab] Cancel database query on stop

smacker opened a new pull request #7611: [sqllab] Cancel database query on stop
URL: https://github.com/apache/incubator-superset/pull/7611
 
 
   ### CATEGORY
   
   Choose one
   
   - [ ] Bug Fix
   - [x] Enhancement (new features, refinement)
   - [ ] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   
   ### SUMMARY
   
   Sorry for submitting PR without creating an issue first. It doesn't look like a big change but I can convert the issue and proposal into SIP if needed.
   
   #### The issue
   SQL Lab has Stop button but it only updates state of superset without actually stopping the database query.
   In some cases complex query can run in background for days and affect database performance.
   The issue especially affect us as we use Superset with [gitbase](http://github.com/src-d/gitbase) which speeks MySQL protocol.
   
   #### This commit solves the problem as following:
   
   1. Add new attribute into Query model that keeps ID of an underlying
   connection to database for this query
   2. Add `get_connection_id` method to EngineSpec that retrieves connection
   id for a cursor.
   3. `execute_sql_statements` before executing queries retrieves and saves
   connection id into Query
   4. Stop handler calls new `cancel_query` method of EngineSpec
   
   Both new methods are implemented only for MySQL for now but it is easy
   to add support for PostgreSQL, MSSQL and maybe some other DBs.
   
   For MySQL I use `KILL CONNECTION` to terminate multiple statements.
   
   #### Alternative approach:
   
   Maintain list of open connections and close them on cancel.
   This solutions looks cleaner but has some disadvantages:
   - would require big changes in the codebase
   - implementation would get very tricky in distrubited mode
   - some drivers can keep query running even after `close()` call.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A
   
   ### TEST PLAN
   
   Run complex log-running query with MySQL using SQL lab. Press stop. The query should be killed.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [x] Requires DB Migration.
   - [x] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   ### REVIEWERS
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org