From a4eb342cd79cca36a90e9154e58370066680df5d 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 --- 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 ab4d7169a2..7c7420ac62 100644 --- a/trytond/trytond/backend/postgresql/database.py +++ b/trytond/trytond/backend/postgresql/database.py @@ -264,7 +264,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)