codeant-ai-for-open-source[bot] commented on code in PR #45178:
URL: https://github.com/apache/superset/pull/45178#discussion_r4254716229
##########
superset/commands/sql_lab/execute.py:
##########
@@ -164,6 +164,18 @@ def _run_sql_json_exec_from_scratch(self) ->
SqlJsonExecutionStatus:
self._query_dao.update(
query, {"limit": self._execution_context.query.limit}
)
+ # Commit now, before dispatch. The async executor below hands off
to
+ # a Celery worker that re-fetches this query on its own connection
+ # (`get_query` in superset/sql_lab.py); under READ COMMITTED that
+ # worker only sees the limit recomputed just above once it is
+ # committed. `@transaction()` on `run()` only commits after this
+ # whole method returns, which is too late: `.delay()` can hand the
+ # task to an already-idle worker before that commit lands, so the
+ # worker reads back the row's limit as it was at creation time (the
+ # raw dropdown value from `create_query()`) instead of the smaller
+ # value just computed from the query's own SQL LIMIT. Same race and
+ # fix as apache/superset#40070.
+ db.session.commit() # pylint: disable=consider-using-transaction
Review Comment:
**Suggestion:** When a Jinja addon stages writes on `db.session`, this
commits them before dispatch; if dispatch fails, `run()`'s rollback cannot undo
those writes.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Logic error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c331e1f2a21a42a69085bf27ad897941&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c331e1f2a21a42a69085bf27ad897941&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/sql_lab/execute.py
**Line:** 178:178
**Comment:**
*Logic Error: When a Jinja addon stages writes on `db.session`, this
commits them before dispatch; if dispatch fails, `run()`'s rollback cannot undo
those writes.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45178&comment_hash=c6976925da3e7fb06e3a773f941ef3247957be6b75fedaad27be0708ae2f8dbe&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45178&comment_hash=c6976925da3e7fb06e3a773f941ef3247957be6b75fedaad27be0708ae2f8dbe&reaction=dislike'>๐</a>
--
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]