mirror of
https://github.com/element-hq/synapse.git
synced 2026-06-08 00:03:15 +00:00
b457462c70
1 new file created, 6 new tests, all passing, mypy clean, no regressions. synapse/storage/native_database.py — NativeConnectionPool class: - Uses concurrent.futures.ThreadPoolExecutor + asyncio.loop.run_in_executor() instead of twisted.enterprise.adbapi.ConnectionPool - Thread-local connection management: each thread in the pool maintains its own persistent DB connection - Automatic connection creation and initialization via engine.on_new_connection() (same as the Twisted pool's cp_openfun) - Reconnection support for closed connections - runWithConnection(func, *args) — runs function on a pool thread with a connection - runInteraction(func, *args) — runs function in a transaction with auto-commit/rollback - close() — shuts down the executor - threadID() — compatibility method for transaction limit tracking The existing DatabasePool and all 846+ runInteraction callers are untouched. When the migration reaches the point of switching DatabasePool to use NativeConnectionPool instead of adbapi.ConnectionPool, the inner_func pattern in runWithConnection will be reused with minimal changes (just swap make_deferred_yieldable(self._db_pool.runWithConnection(...)) to await self._native_pool.runWithConnection(...)).