src-d/sourced-ui

Stopping queries running with Gitbase doesn't work

se7entyse7en opened this issue · 4 comments

Stopping queries running with Gitbase doesn't work

More context: queries seem to be cancelled correctly from superset point of view, there are no errors reported to the user. But the query will continue running in gitbase, which means superset cancels by forgetting about the results, but not calling KILL.

Superset doesn't really stop query.
The source code of the stop endpoint: https://github.com/src-d/superset-compose/blob/master/superset/superset/views/core.py#L2456
It only updates Query model instance in database changing the status.

The model: https://github.com/src-d/superset-compose/blob/master/superset/superset/models/sql_lab.py#L36
It doesn't have any hook that would cancel underlying queries.

Running query calls db_engine_spec.execute at the end: https://github.com/src-d/superset-compose/blob/master/superset/superset/sql_lab.py#L191

There is no hook to check status and cancel the query on EngineSpec level. handle_cursor is called only when the query is finished.

I'm currently exploring how difficult it is to add query cancelation support.

I implemented cancellation: https://github.com/src-d/superset-compose/pull/53/files
But it doesn't work due to a bug in gitbase: src-d/gitbase#817

The PR also doesn't have tests. Most probably after tests are written it makes sense to rebase on superset master and suggest the change to upstream.

fixed