Skip to content

Commit c9aaa9b

Browse files
committed
fix: do not retry on wrong password (28P01) with sslmode=allow/prefer
1 parent db8ecc2 commit c9aaa9b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

asyncpg/connect_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,14 @@ async def __connect_addr(
11031103
except (
11041104
exceptions.InvalidAuthorizationSpecificationError,
11051105
exceptions.ConnectionDoesNotExistError, # seen on Windows
1106-
):
1106+
) as exc:
11071107
tr.close()
1108-
1108+
1109+
# Do not retry on wrong password (28P01) — the issue is credentials,
1110+
# not SSL negotiation. Only pg_hba.conf rejections (28000) warrant a retry.
1111+
if isinstance(exc, exceptions.InvalidPasswordError):
1112+
raise
1113+
11091114
# retry=True here is a redundant check because we don't want to
11101115
# accidentally raise the internal _RetryConnectSignal to the user
11111116
if retry and (

0 commit comments

Comments
 (0)