From 8a8f9f966d0895323ed8934860d3cb65690fbdb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 26 Aug 2024 09:33:58 +0200 Subject: [PATCH] Retry to get a connection when an OperationalError is raised If there are no connection available in the pool, psycopg2 tries to create a new connection but it may raise an OperationalError if the server close it. Closes #13475 (grafted from cecbc1736f2d0fdd8a77c1dcdfe81e23cf99f451) --HG-- branch : 7.0 --- trytond/trytond/backend/postgresql/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/trytond/backend/postgresql/database.py b/trytond/trytond/backend/postgresql/database.py index 59de18962b..126998fe08 100644 --- a/trytond/trytond/backend/postgresql/database.py +++ b/trytond/trytond/backend/postgresql/database.py @@ -259,7 +259,7 @@ class Database(DatabaseInterface): for count in range(retry, -1, -1): try: conn = self._connpool.getconn() - except PoolError: + except (PoolError, DatabaseOperationalError): if count and not self._connpool.closed: logger.info('waiting a connection') time.sleep(1)