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

   ### SUMMARY
   
   Chart-data requests could fail with `PendingRollbackError` from 
`security_manager.find_user()` in `Database._get_sqla_engine()`.
   
   That lookup isn't the cause. Earlier steps in the same request catch a DB 
error, treat it as non-fatal, and carry on **without rolling back** — leaving 
`db.session` in a failed transaction. Every later statement on that session 
then fails with `PendingRollbackError`, so whoever reads it next takes the 
blame. Guarding the lookup alone would just move the error to the next reader.
   
   **Fix:** roll back at the five swallow sites — `utils/rls.py`,
   `models/helpers.py`, `common/utils/query_cache_manager.py`,
   `common/query_context_processor.py`, `jinja_context.py`. This follows the
   existing idiom and completes #43883, which fixed the same bug in a sibling
   function and missed these.
   
   **Also:** the impersonation email lookup existed in four copies (core plus
   StarRocks, Snowflake, gsheets), each able to fail the same way. Consolidated
   into `find_user_for_impersonation()` behind two `Database` methods, so engine
   specs no longer do their own lookup. It rolls back and retries once.
   
   Two behaviour changes worth flagging:
   
   - A lookup still failing after the retry now **raises** instead of falling 
back
     to the un-resolved login. That value becomes the identity the analytic DB
     connects as, so falling back could run the query as a different principal.
     (An unknown user is unaffected — that's a successful lookup returning 
`None`.)
   - Fixes a latent gsheets bug: it looked up a username that had already been
     substituted to an email prefix, so `subject` was silently left unset 
whenever
     login and prefix differed.
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] 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
   


-- 
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