-
Notifications
You must be signed in to change notification settings - Fork 15
[sqllab] Cancel query to database on query stop #53
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
Conversation
Tested with gitbase rc3 and it works like a charm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I commented a couple of places where it seems that the only change is formatting, we may want to revert them to make it cleaner to upgrade/merge things from upstream.
superset/superset/sql_lab.py
Outdated
@@ -193,7 +194,8 @@ def execute_sql_statement(sql_statement, query, user_name, session, cursor): | |||
db_engine_spec.handle_cursor(cursor, query, session) | |||
|
|||
with stats_timing('sqllab.query.time_fetching_results', stats_logger): | |||
logging.debug('Fetching data for query object: {}'.format(query.to_dict())) | |||
logging.debug( | |||
'Fetching data for query object: {}'.format(query.to_dict())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
superset/superset/sql_lab.py
Outdated
@@ -308,9 +313,28 @@ def execute_sql_statements( | |||
cache_timeout = database.cache_timeout | |||
if cache_timeout is None: | |||
cache_timeout = config.get('CACHE_DEFAULT_TIMEOUT', 0) | |||
results_backend.set(key, zlib_compress(json_payload), cache_timeout) | |||
results_backend.set(key, zlib_compress( | |||
json_payload), cache_timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
- Add new attribute into Query model that keeps ID of an underlying connection to database for this query - Add `get_connection_id` method to EngineSpec that retrieves connection id for a cursor. - `execute_sql_statements` before executing queries retrieves and saves connection id into Query - Stop handler calls new `cancel_query` method of EngineSpec Both new methods are implemented only for MySQL for now. `cancel_query` uses KILL CONNECTION to terminate the statement. Signed-off-by: Maxim Sukharev <[email protected]>
thanks! fixed & rebased on master |
connection to database for this query
get_connection_id
method to EngineSpec that retrieves connectionid for a cursor.
execute_sql_statements
before executing queries retrieves and savesconnection id into Query
cancel_query
method of EngineSpecBoth new methods are implemented only for MySQL for now.
cancel_query
uses KILL CONNECTION to terminate the statement.Ref: #35