Skip to content

Commit a9bcab9

Browse files
Add id(self) suffix to "Pool is closed" errors
The Pool is closed DqliteConnectionError previously gave operators no way to identify which pool instance was the offender — a process can hold multiple pools (rw + ro split, per-tenant, sharded) and the generic message landed in centralised logs identically for every one. Add an `(id={id(self)})` suffix so a traceback can be correlated against the pool-warm-up logs that already include id(self). The pool-is-closed message is not classifier-load-bearing on the SA side (the pool failure surfaces as DqliteConnectionError wrapped to OperationalError("Failed to connect: ...") from dbapi's connect() arm, where is_disconnect uses a different match path), so the fragment shape is freer than the dbapi-side closed-handle messages. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8ea4ed7 commit a9bcab9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/dqliteclient/pool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,15 +773,15 @@ async def acquire(self) -> AsyncIterator[DqliteConnection]:
773773
"Pool used after fork; reconstruct from configuration in the target process."
774774
)
775775
if self._closed:
776-
raise DqliteConnectionError("Pool is closed")
776+
raise DqliteConnectionError(f"Pool is closed (id={id(self)})")
777777

778778
loop = asyncio.get_running_loop()
779779
deadline = loop.time() + self._timeout
780780
conn: DqliteConnection | None = None
781781

782782
while conn is None:
783783
if self._closed:
784-
raise DqliteConnectionError("Pool is closed")
784+
raise DqliteConnectionError(f"Pool is closed (id={id(self)})")
785785

786786
# Try to get an idle connection from the queue
787787
try:
@@ -796,7 +796,7 @@ async def acquire(self) -> AsyncIterator[DqliteConnection]:
796796
reserved = False
797797
async with self._lock:
798798
if self._closed:
799-
raise DqliteConnectionError("Pool is closed")
799+
raise DqliteConnectionError(f"Pool is closed (id={id(self)})")
800800
if self._size < self._max_size:
801801
self._size += 1
802802
reserved = True
@@ -846,7 +846,7 @@ async def acquire(self) -> AsyncIterator[DqliteConnection]:
846846
async with self._lock:
847847
closed_event = self._get_closed_event()
848848
if self._closed:
849-
raise DqliteConnectionError("Pool is closed")
849+
raise DqliteConnectionError(f"Pool is closed (id={id(self)})")
850850
closed_event.clear()
851851
logger.debug(
852852
"pool.acquire: at capacity size=%d max=%d, waiting",
@@ -1025,7 +1025,7 @@ async def acquire(self) -> AsyncIterator[DqliteConnection]:
10251025
await asyncio.shield(conn.close())
10261026
with contextlib.suppress(asyncio.CancelledError):
10271027
await asyncio.shield(self._release_reservation())
1028-
raise DqliteConnectionError("Pool is closed")
1028+
raise DqliteConnectionError(f"Pool is closed (id={id(self)})")
10291029

10301030
conn._pool_released = False
10311031
try:

0 commit comments

Comments
 (0)