rusackas commented on PR #40237:
URL: https://github.com/apache/superset/pull/40237#issuecomment-4580230683

   **Root cause of the postgres CI failures — fixed in the latest commit.**
   
   `get_sqla_engine` registers a SQLAlchemy `"connect"` event listener on the 
engine to run prequeries (e.g. `SET search_path = "sqllab_test_db"` for 
PostgreSQL schema scoping). Before this PR each call created a fresh engine, so 
those listeners died with the engine. With the engine cache the same `Engine` 
object is reused — but the listener was never removed when the context manager 
exited.
   
   Result: a test that called `get_sqla_engine(schema='sqllab_test_db')` left a 
`SET search_path` listener on the shared cached engine. The next test that 
called `get_sqla_engine(schema=None)` got the same cached engine, and any new 
DBAPI connection it opened automatically ran `SET search_path = 
"sqllab_test_db"`, making `birth_names` (which lives in `public`) invisible.
   
   Fix: wrap the `yield engine` in `try/finally` and call 
`sqla.event.remove(engine, "connect", run_prequeries)` so the listener lifetime 
matches the context manager lifetime.


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