mirror of
https://github.com/apache/superset.git
synced 2026-09-07 15:54:55 +00:00
SQLAlchemy 2.0 changed the default poolclass for file-based SQLite engines from NullPool to QueuePool. Under 1.4, every checkout created a fresh low-level sqlite3 connection, so a pooled connection was never handed to a thread other than the one that opened it. QueuePool reuses connections across checkouts, including checkouts from background threads such as the GTF task framework's deferred-flush timer (superset/tasks/context.py). Combined with the test suite's `?check_same_thread=true` SQLite URIs, a connection opened on the main thread can now be handed to a background timer thread, which pysqlite rejects with "SQLite objects created in a thread can only be used in that same thread." This silently broke the deferred DB write in TaskContext._deferred_flush, intermittently failing tests/integration_tests/tasks/test_throttling.py::test_throttle_behavior under full-suite load (reproduced deterministically across two full sqlite runs, passed in isolation, confirmed via QueuePool + NullPool introspection against the pinned 1.4.54 and 2.0.51 wheels). Pin poolclass=NullPool for the sqlite test lane to restore the 1.4 behavior. Superset's non-test default config uses `check_same_thread=false` instead, which is unaffected by pooled cross-thread connection reuse, so this is scoped to the test config rather than superset/config.py.