Skip to content
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

[sql lab] Fix setting async query status to timed_out #7429

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import pandas as pd
import simplejson as json
import sqlalchemy as sqla
from sqlalchemy import and_, create_engine, MetaData, or_, update
from sqlalchemy import create_engine, MetaData, or_
from sqlalchemy.engine.url import make_url
from sqlalchemy.exc import IntegrityError
from werkzeug.routing import BaseConverter
Expand Down Expand Up @@ -2752,12 +2752,10 @@ def queries(self, last_updated_ms):
]

if queries_to_timeout:
update(Query).where(
and_(
Query.user_id == g.user.get_id(),
Query.client_id in queries_to_timeout,
),
).values(state=QueryStatus.TIMED_OUT)
for q in sql_queries:
Copy link
Member

@john-bodley john-bodley May 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many SQL queries are there? It may be more efficient to have the database (like before) handle this logic.

The issue here is that update(...) returns an expression which then needs to be executed and committed.

if q.client_id in queries_to_timeout:
q.status = QueryStatus.TIMED_OUT
db.session.commit()

for client_id in queries_to_timeout:
dict_queries[client_id]['status'] = QueryStatus.TIMED_OUT
Expand Down