dosubot[bot] commented on issue #40996: URL: https://github.com/apache/superset/issues/40996#issuecomment-4689892448
<!-- Answer --> Hi @dijoux! I'm [Dosu](https://go.dosu.dev/dosubot) and I'm helping the Apache Superset team. Your analysis is correct — this is a legitimate race condition caused by Superset's nested `@transaction` decorator pattern. Here's what's happening: the outer transaction in `ReportScheduleStateMachine.run()` [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/commands/report/execute.py#L848-L859) sets a `g.in_transaction` flag. When `CreateDashboardPermalinkCommand.run()` is called inside it, the `@transaction` decorator detects the existing transaction and [skips its own commit logic](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/decorators.py#L239-L279), just executing the function directly. The permalink is only [flushed to the session](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/commands/dashboard/permalink/create.py#L80) (visible within the current transaction) but **not committed** to the database. When Playwright then navigates to that permalink URL, it triggers a separate HTTP request on a different database connection [[2]](https://github.com/apache/super set/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/webdriver.py#L162-L165) that cannot see the uncommitted row — resulting in the failure you observed. Your fix of adding `db.session.commit()` after `CreateDashboardPermalinkCommand.run()` in `_get_tab_url` is a reasonable workaround [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/commands/report/execute.py#L273-L287). One thing to be aware of: calling `commit()` mid-transaction will commit all pending changes in that session (not just the permalink), which could have side effects if other uncommitted state exists at that point. A more surgical approach might be to use a `SAVEPOINT` (nested transaction) or to restructure so the permalink creation happens in an independent session/transaction, but for practical purposes your fix should work. This doesn't appear to have an existing fix or open PR addressing it directly — [PR #40530](https://github.com/apache/superset/pull/40530) worked around related Playwright timeout issues by skipping permalink creation for empty dashboard states, but didn't address the commit timing problem itself. You may want to consider opening a PR with your fix. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=57f2bb31-55f4-404f-9b51-b6e74b52dc36) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset) -- 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]
