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

   ### SUMMARY
   
   This is a **test-only PR** opened as a TDD-style validation of issue #27897.
   
   #27897 (filed 2024-04) reports that `Database._get_sqla_engine` calls 
`create_engine` on every invocation instead of caching the engine per URL. Per 
SQLAlchemy docs an engine is meant to be created once per process per URL so 
its connection pool can do its job; the current behavior defeats the pool every 
time `DB_CONNECTION_MUTATOR` configures one.
   
   This PR adds one regression test on `Database._get_sqla_engine`:
   
   1. **`test_get_sqla_engine_caches_engine_per_url`** — patches 
`create_engine`, calls `_get_sqla_engine(nullpool=False)` twice for the same 
URL, and asserts `create_engine` was called exactly once. Will fail until the 
engine is cached.
   
   ### How to interpret CI
   
   - **CI green** → engine caching has been added since the report; merging 
closes #27897 and locks in the regression guard.
   - **CI red** → bug is still live (most likely outcome). Likely fix: 
introduce a per-URL engine cache in `Database._get_sqla_engine` (or hoist into 
a module-level dict keyed by sqlalchemy_url + connect_args).
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest 
tests/unit_tests/models/core_test.py::test_get_sqla_engine_caches_engine_per_url
 -v
   ```
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: closes #27897
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] 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