bito-code-review[bot] commented on PR #43889:
URL: https://github.com/apache/superset/pull/43889#issuecomment-5552738978
<!-- Bito Reply -->
The flagged issue is correct. The current implementation of `stop_query` in
`superset/daos/query.py` uses the `@transaction()` decorator, which ensures
that the `early-cancel` flag (staged by `cancel_query()`) and the `status =
QueryStatus.STOPPED` assignment are committed atomically. This prevents the
race condition where a query could be observed in a `RUNNING` state while
having an `early-cancel` marker committed.
No further changes are required to resolve this specific issue, as the
implementation already addresses the race condition described in the comment.
Would you like me to check the other comments on this PR to see if there are
additional issues to address?
**superset/daos/query.py**
```
@staticmethod
@transaction()
def stop_query(client_id: str) -> None:
query = (
db.session.query(Query)
.filter_by(client_id=client_id)
.one_or_none()
)
if not query:
raise SupersetCancelQueryException("Query not found")
if not sql_lab.cancel_query(query):
raise SupersetCancelQueryException("Could not cancel query")
# cancel_query() may have staged an early-cancel flag on query.extra
# without committing it (see its docstring/comments); the
# @transaction decorator commits it together with status=STOPPED
# below in one transaction, closing the window where another
# request could observe the flag set but the status still RUNNING.
query.status = QueryStatus.STOPPED
query.end_time = now_as_float()
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]