mikebridge opened a new pull request, #44928:
URL: https://github.com/apache/superset/pull/44928

   ### SUMMARY
   
   Core consulted the host's `VERSIONING_CAPTURE_PREDICATE` on every flush and 
commit, whether or not the unit of work touched a versioned model. Writes that 
have nothing to do with versioning (SQL Lab query status rows, user upserts, 
permalinks, report logs) therefore paid for the host's policy lookup, which for 
a multi-tenant host can mean remote calls.
   
   The predicate is now consulted only once a flush holds a versioned instance 
or retained initial state. The decision is still made once per transaction and 
frozen, and the baseline listener, the change listener and 
`finalize_change_records` all read that one decision, so a later flush in the 
same transaction cannot see a different answer. With the predicate off or 
raising, behaviour is unchanged.
   
   Measured with a counting predicate in the unit tests:
   
   | Sequence | Predicate calls before | After |
   |---|---|---|
   | Two non-versioned flushes plus an empty commit | 7 | 0 |
   | A versioned delete and commit | 4 | 1 |
   
   The read path (`api_helpers`) is unchanged; it has no pending write to key 
on and is a separate optimization.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A (backend).
   
   ### TESTING INSTRUCTIONS
   
   - `pytest tests/unit_tests/versioning`: 415 passed, 2 xfailed.
   - New tests cover non-versioned-first and versioned-first transactions with 
the predicate on and off, baseline and child capture, a raising predicate, 
released savepoints, autoflush during a query, and hard and soft deletes. An 
independent review compared the history rows written before and after this 
change across seven write sequences and found them identical.
   - **Two strict xfails:** a versioned insert that is rolled back inside a 
savepoint, followed by another versioned insert in the same outer transaction, 
fails on master today (a stale `*_version` UPDATE, then `no such savepoint`). 
It fails identically with this change, with the same rows written, so it is 
marked `xfail(strict=True)` here pending a separate fix. No application code 
path on master was found that performs that sequence.
   
   ### 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))
   - [ ] 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: [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]

Reply via email to