]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Handle "SSL SYSCALL error: Success" in psycopg2 11523/head
authorDavid H. Irving <david.irving@noirlab.edu>
Fri, 21 Jun 2024 17:57:37 +0000 (10:57 -0700)
committerDavid H. Irving <david.irving@noirlab.edu>
Fri, 21 Jun 2024 17:59:26 +0000 (10:59 -0700)
It is now considered a pool-invalidating disconnect event when psycopg2
throws an "SSL SYSCALL error: Success" error message, which can occur
when the SSL connection to Postgres is terminated abnormally.

Fixes: #11522
doc/build/changelog/unreleased_20/11522.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/psycopg2.py
test/dialect/postgresql/test_dialect.py

diff --git a/doc/build/changelog/unreleased_20/11522.rst b/doc/build/changelog/unreleased_20/11522.rst
new file mode 100644 (file)
index 0000000..279197a
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, postgresql
+    :tickets: 11522
+
+    It is now considered a pool-invalidating disconnect event when psycopg2
+    throws an "SSL SYSCALL error: Success" error message, which can occur when
+    the SSL connection to Postgres is terminated abnormally.
\ No newline at end of file
index 6c492a5b2501fd12d1db344b53a69ce4f04175f0..6d4e8e1c7d4b7760441810c318c49966b037373a 100644 (file)
@@ -866,6 +866,12 @@ class PGDialect_psycopg2(_PGDialect_common_psycopg):
                 "SSL SYSCALL error: EOF detected",
                 "SSL SYSCALL error: Operation timed out",
                 "SSL SYSCALL error: Bad address",
+                # This can occur in OpenSSL 1 when an unexpected EOF occurs.
+                # https://www.openssl.org/docs/man1.1.1/man3/SSL_get_error.html#BUGS
+                # It may also occur in newer OpenSSL for a non-recoverable I/O
+                # error as a result of a system call that does not set 'errno'
+                # in libc.
+                "SSL SYSCALL error: Success",
             ]:
                 idx = str_e.find(msg)
                 if idx >= 0 and '"' not in str_e[:idx]:
index eae1b55d6e99c79b69c53e85283ec4c8a98c115c..3f55c085fb4cfaa96a68a088d75c7e183bd38382 100644 (file)
@@ -365,6 +365,7 @@ $$ LANGUAGE plpgsql;"""
             "SSL SYSCALL error: EOF detected",
             "SSL SYSCALL error: Operation timed out",
             "SSL SYSCALL error: Bad address",
+            "SSL SYSCALL error: Success",
         ]:
             eq_(dialect.is_disconnect(Error(error), None, None), True)