You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mikebridge (via GitHub)" <gi...@apache.org> on 2026/09/08 21:29:16 UTC
[PR] fix(dataset): refresh the entity under the conditional-write row lock [superset]
mikebridge opened a new pull request, #44027:
URL: https://github.com/apache/superset/pull/44027
### SUMMARY
The dataset PUT's conditional-write path (`If-Match` saves) serialises check-and-write by row-locking the entity first (`lock_entity_for_update`, called from `superset/datasets/api.py`). But the lock was an id-only `SELECT id ... FOR UPDATE` that discarded the row's values — it serialised writers without refreshing what the transaction can *see*:
- On MySQL/InnoDB default **REPEATABLE READ**, every consistent read in a transaction is pinned to the read view established by its first read (the request's auth queries run well before the lock). So the entity loaded after that id-only lock still reflected the **pre-lock snapshot**, and the ORM — which only emits `UPDATE`s for attributes that differ from the *loaded* values — could silently lose a concurrent commit that landed between the initial load and the lock. This is the same class as the version-restore partial-write fixed in #44015, on the ordinary update path.
- The staleness is also **object-level on every backend**: SQLAlchemy never refreshes an already-loaded entity from a later plain `SELECT`, so even where the row read is fresh (Postgres READ COMMITTED), the identity-map object the update command operates on stayed stale.
**Fix** (mirroring #44015's locking-refresh): take the lock as a full-entity ORM read — `db.session.query(model).populate_existing().filter(id).with_for_update().one_or_none()`. A locking read is exempt from the REPEATABLE READ snapshot and returns current committed data; `populate_existing()` writes it into the identity-map object, which the update command's later `find_by_id` returns without re-hydrating from its own (possibly stale) row. Missing-row semantics are unchanged: the result is discarded and existence keeps being decided by the command's own lookup (404 as before). Chart/dashboard PUTs have no conditional-write lock path, so the fix is dataset-scoped at the single shared helper.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — concurrency fix with no UI or response-shape change.
### TESTING INSTRUCTIONS
- `pytest tests/unit_tests/versioning/test_lock_entity.py` — 3 tests: the dialect-independent regression guard pins the statement shape (`populate_existing()` **and** `with_for_update()` both chained, result consumed via `one_or_none()`; dropping either fails on every backend — the analogue of #44015's `refresh(..., with_for_update=True)` pin), plus the non-numeric/None id early-outs that keep the `/<pk>` string route from raising a SQL cast error. Reverting the helper flips the shape test.
- `pytest tests/integration_tests/versioning/conditional_write_lock_tests.py` — two-transaction behavioral proof: a second engine-level connection commits a change between this session's entity load and the lock; after `lock_entity_for_update` the loaded entity must show the concurrently committed value (fails pre-fix on every backend, since the staleness is object-level), plus a quiet-path control asserting the refresh is a no-op (and dirties nothing) when nothing changed underneath. Skipped on SQLite, where a second writer connection deadlocks against the open read transaction instead of modelling a concurrent request — CI's Postgres/MySQL runs execute them (local env here is SQLite-backed, so these two are CI-verified).
- Manual (MySQL): open a dataset edit in one tab; from a second session commit a change to another field; save the first tab with `If-Match`. Before the fix the first save's flush could quietly discard the concurrent change on MySQL; after, the command diffs against committed state.
### 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)
https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
--
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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #44027:
URL: https://github.com/apache/superset/pull/44027
--
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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "mikebridge (via GitHub)" <gi...@apache.org>.
mikebridge commented on PR #44027:
URL: https://github.com/apache/superset/pull/44027#issuecomment-5638015109
Dependency note for reviewers: this PR closes the **entity-read** half of the MySQL REPEATABLE READ conditional-write race; #44091 (in review) closes the **validator-read** half (`current_entity_version_info` otherwise still serves a snapshot transaction id, so a stale `If-Match` can pass). The race is fully shut only with both merged — either order works; the PR bodies carry the rebase caveats.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
--
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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #44027:
URL: https://github.com/apache/superset/pull/44027#issuecomment-5592242596
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ac59e41c91ed74db2e963441ac4e6df413fda9ae |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6aa08056dde064000751082d |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-44027--superset-docs-preview.netlify.app](https://deploy-preview-44027--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpBCoAgEAXQu8y6gW-kRTfoGOYIRZZS0yKiu-fuLd5L5cx7URqJGppPf4Sl-gpsWsB0XG7llMPGl_oUOR666lOrxJLyM0nNznsMsE4kwnUAemswtELfDw) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-44027--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44027:
URL: https://github.com/apache/superset/pull/44027#issuecomment-5595171422
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers an incremental AI Review.
- `/review full` - Manually triggers a full AI Review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "mikebridge (via GitHub)" <gi...@apache.org>.
mikebridge commented on PR #44027:
URL: https://github.com/apache/superset/pull/44027#issuecomment-5593521756
@aminghadersohi — requesting review on the conditional-write lock fix (sc-120014), the update-path sibling of #44015's restore fix and squarely in your versioning lane.
The dataset PUT's `If-Match` path row-locked the entity with an id-only `SELECT ... FOR UPDATE` that discarded the values. On MySQL/InnoDB REPEATABLE READ, the transaction's read view is pinned by its first consistent read (the request's auth queries), so the entity the update command loaded after that lock still reflected the pre-lock snapshot — and the ORM, which only emits UPDATEs for attributes differing from the *loaded* values, could silently lose a concurrent commit that landed between the load and the lock.
Fix: the lock is now a full-entity ORM read — `populate_existing()` + `with_for_update()` — so the locking read (exempt from the RR snapshot) writes current committed data into the identity-map object the command's `find_by_id` returns. Two hardenings from the adversarial review rounds worth knowing:
- **Lifetime contract**: the helper *returns* the locked entity and the dataset PUT binds it for the rest of the request — the identity map references clean objects weakly, so a discarded result was collectible immediately, which would have silently reduced the fix to a production no-op (caught by the cross-model committer pass). Pinned both ways: held → `find_by_id` returns the very same refreshed instance; discarded → a weakref proves collection.
- **Scoped honestly**: the refresh covers the entity row; the If-Match validator's own version-info reads (and lazy child-collection loads) have the same RR staleness one layer up and are tracked as a separate follow-up rather than folded in — the docstrings and the endpoint comment say exactly what is and isn't covered.
Tests: 3 unit statement-shape pins (dropping either flag fails on every backend; mirrors #44015's refresh-flag guard) + 3 two-transaction integration tests (object-level staleness, so the interleave test fails pre-fix on every backend it runs on; SQLite skipped — a second writer connection can't model a concurrent request there). CI green including the full DB matrix.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
--
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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44027:
URL: https://github.com/apache/superset/pull/44027#issuecomment-5592124412
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44027:
URL: https://github.com/apache/superset/pull/44027#issuecomment-5592190023
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44027?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 `0%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 57.48%. Comparing base ([`7029c46`](https://app.codecov.io/gh/apache/superset/commit/7029c468c4d58b40c695b49c4f2a7806a05f1ddb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`98847ad`](https://app.codecov.io/gh/apache/superset/commit/98847ad780773ca646884bbc91aba98b1395ac79?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 2 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/44027?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/versioning/api\_helpers.py](https://app.codecov.io/gh/apache/superset/pull/44027?src=pr&el=tree&filepath=superset%2Fversioning%2Fapi_helpers.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmVyc2lvbmluZy9hcGlfaGVscGVycy5weQ==) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44027?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 (7029c46) and HEAD (98847ad). Click for more details.
>
> <details><summary>HEAD has 6 uploads less than BASE</summary>
>
>| Flag | BASE (7029c46) | HEAD (98847ad) |
>|------|------|------|
>|python|7|1|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #44027 +/- ##
===========================================
- Coverage 79.85% 57.48% -22.37%
===========================================
Files 2916 2916
Lines 170691 170691
Branches 39550 39550
===========================================
- Hits 136307 98126 -38181
- Misses 31867 71643 +39776
+ Partials 2517 922 -1595
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/44027/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/44027/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/44027/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/44027/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/44027/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.47% <0.00%> (ø)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/44027/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.47% <0.00%> (-44.79%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/44027/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/44027/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/44027?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(dataset): refresh the entity under the conditional-write row lock [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44027:
URL: https://github.com/apache/superset/pull/44027#issuecomment-5640119485
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers an incremental AI Review.
- `/review full` - Manually triggers a full AI Review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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