SIGN IN SIGN UP
apache / superset UNCLAIMED

Apache Superset is a Data Visualization and Data Exploration Platform

0 0 150 TypeScript

fix(database): cache sqla engine per process per URL (#27897)

Wires up _ENGINE_CACHE — a module-level dict keyed by
(database_id, str(sqlalchemy_url), repr(sorted(engine_kwargs.items())))
— so that successive _get_sqla_engine(nullpool=False) calls reuse the
same Engine instance instead of building a fresh one each invocation.
Per SQLAlchemy docs the engine is meant to live for the process lifetime;
recreating defeats every pool an operator configures via
DB_CONNECTION_MUTATOR (the original bug report's duckdb queue-size-1
seeing multiple simultaneous connections).

nullpool=True engines are skipped — those are intentionally poolless and
there's nothing to reuse.

The regression test added in the prior commit clears _ENGINE_CACHE in
its setup so test ordering can't smuggle a stale entry past the
assertion.

Closes #27897
C
Claude committed
9a6f76c9926a0decd810aad59510ce73c50fbe82
Parent: 125624e