You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "michael-s-molina (via GitHub)" <gi...@apache.org> on 2026/10/07 17:43:32 UTC
[PR] fix(permalink): handle concurrent creation of identical dashboard permalinks [superset]
michael-s-molina opened a new pull request, #45059:
URL: https://github.com/apache/superset/pull/45059
### SUMMARY
`CreateDashboardPermalinkCommand` is a get-or-create. It derives a deterministic UUID from the user and the dashboard state (so the same user and state always map to the same permalink), looks the entry up in the key-value store, and inserts it if it is missing.
The lookup and the insert are not atomic. When several identical requests arrive at the same time, each one misses the lookup and tries to insert the same UUID. One insert wins and the others violate the unique index on `key_value.uuid` (MySQL error 1062, or the equivalent PostgreSQL unique violation). The command wraps that error in `DashboardPermalinkCreateFailedError` and the API returns an HTTP 500, even though the permalink exists and is exactly what the caller asked for.
**Use case.** Embedded dashboards, and any integration that creates permalinks programmatically, can issue several identical permalink creation requests at once (for example from multiple components on a page, several tabs, or a duplicated or retried client call), with the requests spread across multiple web workers. All of these requests are legitimate and should resolve to the same permalink. Under such bursts a fraction of them fail with a 500.
**Fix.** The insert now runs inside a SAVEPOINT. On `IntegrityError` the savepoint is rolled back (the outer transaction stays usable), the entry created by the concurrent request is re-read, and its key is returned. If no entry is found, the error was not the expected duplicate and is re-raised, so unrelated integrity errors are not masked. This is the same pattern used elsewhere in the codebase (for example in task creation).
The re-read relies on `READ COMMITTED`, which is the default isolation level Superset sets for MySQL and PostgreSQL metadata databases.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
### TESTING INSTRUCTIONS
Unit tests (the concurrent-winner test fails without the change and passes with it):
```bash
pytest tests/unit_tests/commands/dashboard/permalink_create_test.py
```
Manual check: send several identical `POST /api/v1/dashboard/<id>/permalink` requests at the same time as the same user, with the same body. Before this change some of them return 500 (`DashboardPermalinkCreateFailedError`); after it, all return 201 with the same permalink key.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
๐ค Generated with [Claude Code](https://claude.com/claude-code)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(permalink): handle concurrent creation of identical dashboard permalinks [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #45059:
URL: https://github.com/apache/superset/pull/45059#discussion_r4210130579
##########
superset/commands/dashboard/permalink/create.py:
##########
@@ -97,14 +97,30 @@ def run(self) -> str:
assert entry.id # for type checks
return encode_permalink_key(key=entry.id, salt=self.salt)
- # Create new entry with current algorithm
- entry = KeyValueDAO.create_entry(
- resource=self.resource,
- key=uuid_key,
- value=value,
- codec=self.codec,
- )
- db.session.flush()
+ # Create new entry with current algorithm.
+ #
+ # The uuid is deterministic, so concurrent identical requests (same user,
+ # dashboard and state) all try to insert the same uuid. The lookup above and
+ # this insert are not atomic, so the unique index is the ultimate arbiter:
+ # the insert runs inside a SAVEPOINT and, if a concurrent request won the
+ # race, we join the winner's entry instead of failing the request.
+ try:
+ with db.session.begin_nested():
+ entry = KeyValueDAO.create_entry(
+ resource=self.resource,
+ key=uuid_key,
+ value=value,
+ codec=self.codec,
+ )
+ db.session.flush()
+ except IntegrityError:
+ # The SAVEPOINT is rolled back and the session is still usable. The
+ # winner's row is committed by now (READ COMMITTED, the default for
+ # MySQL and PostgreSQL metadata databases), so re-read it. If nothing
+ # is found, this was not the expected duplicate, so re-raise.
+ entry = KeyValueDAO.get_entry(self.resource, uuid_key)
Review Comment:
**Suggestion:** `READ COMMITTED` is only the default; with configured `REPEATABLE READ`, this reread can use the earlier snapshot, return `None`, and re-raise the duplicate.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Race condition`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=83f4caff60504280b486d8712ee2cad3&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=83f4caff60504280b486d8712ee2cad3&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/dashboard/permalink/create.py
**Line:** 121:121
**Comment:**
*Race Condition: `READ COMMITTED` is only the default; with configured `REPEATABLE READ`, this reread can use the earlier snapshot, return `None`, and re-raise the duplicate.
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%2F45059&comment_hash=cabe6374ec672ec2825eaaea9903abc0feadb990aada700b5e4c191043566346&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45059&comment_hash=cabe6374ec672ec2825eaaea9903abc0feadb990aada700b5e4c191043566346&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(permalink): handle concurrent creation of identical dashboard permalinks [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #45059:
URL: https://github.com/apache/superset/pull/45059#issuecomment-6043589435
## CodeAnt PR Risk: Medium Risk
- The PR needs attention before merging.
- Under REPEATABLE READ, including MySQLโs default isolation, the reread may not see the concurrent insert and can re-raise the integrity error.
- The unit tests mock the database and do not exercise this isolation-level behavior.
**Assessed commit:** `4ce48da8c33a`
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(permalink): handle concurrent creation of identical dashboard permalinks [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #45059:
URL: https://github.com/apache/superset/pull/45059#discussion_r4210191566
##########
superset/commands/dashboard/permalink/create.py:
##########
@@ -97,14 +97,30 @@ def run(self) -> str:
assert entry.id # for type checks
return encode_permalink_key(key=entry.id, salt=self.salt)
- # Create new entry with current algorithm
- entry = KeyValueDAO.create_entry(
- resource=self.resource,
- key=uuid_key,
- value=value,
- codec=self.codec,
- )
- db.session.flush()
+ # Create new entry with current algorithm.
+ #
+ # The uuid is deterministic, so concurrent identical requests (same user,
+ # dashboard and state) all try to insert the same uuid. The lookup above and
+ # this insert are not atomic, so the unique index is the ultimate arbiter:
+ # the insert runs inside a SAVEPOINT and, if a concurrent request won the
+ # race, we join the winner's entry instead of failing the request.
+ try:
+ with db.session.begin_nested():
+ entry = KeyValueDAO.create_entry(
+ resource=self.resource,
+ key=uuid_key,
+ value=value,
+ codec=self.codec,
+ )
+ db.session.flush()
+ except IntegrityError:
+ # The SAVEPOINT is rolled back and the session is still usable. The
+ # winner's row is committed by now (READ COMMITTED, the default for
+ # MySQL and PostgreSQL metadata databases), so re-read it. If nothing
+ # is found, this was not the expected duplicate, so re-raise.
+ entry = KeyValueDAO.get_entry(self.resource, uuid_key)
Review Comment:
โ
**CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `548e5aa`.
The duplicate-recovery reread now calls `get_entry(..., for_update=True)`, using a locking read so it can see the row committed by the winning transaction under `REPEATABLE READ`.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(permalink): handle concurrent creation of identical dashboard permalinks [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #45059:
URL: https://github.com/apache/superset/pull/45059#issuecomment-6044118197
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/45059?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `55.55556%` with `4 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 66.14%. Comparing base ([`888795b`](https://app.codecov.io/gh/apache/superset/commit/888795b90f9999adabc19263177cf6bb5500e191?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`548e5aa`](https://app.codecov.io/gh/apache/superset/commit/548e5aa5fda48236b6cb1adf92d5bda68eac2658?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/45059?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/commands/dashboard/permalink/create.py](https://app.codecov.io/gh/apache/superset/pull/45059?src=pr&el=tree&filepath=superset%2Fcommands%2Fdashboard%2Fpermalink%2Fcreate.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvZGFzaGJvYXJkL3Blcm1hbGluay9jcmVhdGUucHk=) | 55.55% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/45059?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (888795b) and HEAD (548e5aa). Click for more details.
>
> <details><summary>HEAD has 4 uploads less than BASE</summary>
>
>| Flag | BASE (888795b) | HEAD (548e5aa) |
>|------|------|------|
>|python|7|3|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #45059 +/- ##
===========================================
- Coverage 82.59% 66.14% -16.45%
===========================================
Files 3005 3005
Lines 186925 186931 +6
Branches 43302 43303 +1
===========================================
- Hits 154389 123648 -30741
- Misses 29772 60585 +30813
+ Partials 2764 2698 -66
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage ฮ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.20% <11.11%> (-0.01%)` | :arrow_down: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.05% <11.11%> (-0.01%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `54.94% <55.55%> (-31.47%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `54.82% <55.55%> (-0.01%)` | :arrow_down: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/45059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/45059?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(permalink): handle concurrent creation of identical dashboard permalinks [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina merged PR #45059:
URL: https://github.com/apache/superset/pull/45059
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org