From aec3f43f6b00e8052a0d11d6ff9cfb64e9f77e9d Mon Sep 17 00:00:00 2001 From: Viktor Dick Date: Wed, 15 Jan 2020 08:33:44 +0100 Subject: [PATCH] Add AdminShutdown to errors that can be retried --- Products/ZPsycopgDA/db.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Products/ZPsycopgDA/db.py b/Products/ZPsycopgDA/db.py index 3ca21e0..f297b1f 100644 --- a/Products/ZPsycopgDA/db.py +++ b/Products/ZPsycopgDA/db.py @@ -310,8 +310,13 @@ def handle_retry(self, error): # Errors that only affect our connection and where an immediate retry # should work. + # AdminShutdown sounds bad, but it might only be our connection that is + # affected. When reconnecting after a regular Retry we see if it + # acutually something serious, in which case we will get something like + # 'the database is shutting down'. If it is only our connection, a + # simple reconnect will work. connection_error = ( - name == 'OperationalError' and ( + name in ('AdminShutdown', 'OperationalError') and ( 'server closed the connection' in value or 'terminating connection due to administrator command' in value )