aiokitchen / hasql

hasql - is a library for high available PostgreSQL clusters.
Apache License 2.0
42 stars 7 forks source link

Background task checking pools died #13

Closed tarokinoe closed 1 day ago

tarokinoe commented 2 months ago

Hello! I encountered a case when the task that checks pools died.

https://github.com/aiokitchen/hasql/blob/master/hasql/base.py#L519

    async def _check_pool_task(self, index: int):
            try:
                ...
                await self._periodic_pool_check(pool, dsn, sys_connection)
            finally:
                if sys_connection is not None:
                    try:
                        await self.release_to_pool(sys_connection, pool)
                    except Exception:
                        logger.warning(
                            "Release connection to pool with "
                            "exception for dsn=%r",
                            censored_dsn,
                            exc_info=True,
                        )
                    sys_connection = None

self.release_to_pool called asyncpg.Pool.release, that threw asyncio.CancelledError (BaseException), that is not caught anywhere.

Need to add CancelledError in addition to Exception.