Skip to content

Trino queries cannot be stopped in SQL Lab #24858

Closed
trinodb/trino-python-client
#400
@giftig

Description

@giftig

Trino queries do not get stopped in SQL Lab when hitting the STOP button.

How to reproduce the bug

  1. Configure a trino backend
  2. Run a query against trino, ideally one which takes a few minutes to execute
  3. Hit stop
  4. See the query continue to run (observe logs or check trino interface)

Expected results

Query should be stopped after hitting the stop button.

Actual results

It continues to run until completion

Environment

(please complete the following information):

  • browser type and version: N/A
  • superset version: 2.1
  • python version: N/A
  • node.js version: N/A
  • any feature flags active:
  • trino==0.324.0 but applies to other versions too

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

We've done some additional investigating into why this happens and we're ready to raise a draft PR which I'll attach to this issue. The bottom line is that the trino client doesn't have an async mode, and the query execution call will simply block until the query completes. This means the handle_cursor call we do is useless because we only extract query ID and/or trigger early cancellation events on the query after it's finished, when it's too late.

As a draft fix I've fired the query off in another thread manually and polled for the query ID to be appear asynchronously, and the rest of the stop query code seems to work fine with that in place. See PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions