Skip to content

Commit

Permalink
Refine error messages for detecting lost connections (#53794)
Browse files Browse the repository at this point in the history
Last year I added those two via #47398
Please see details and reasoning there, it still applies; TL;DR:
> Ever since I moved from AWS Aurora to using AWS RDS Proxy, which
> (similar to pgbouncer) is essential to not overload the primary database
> with connection, I sporadically see these messages. This affects
> scheduled tasks, worker, HTTP requests; it's across the whole board.

What I didn't knew back then was that the order/format of those messages
very much dependent on the underlying libraries (libpq and or libssl
presumably) and once we started to upgrade from Debian bullseye to
bookworm, they changed and now are randomly interrupting our service
again.

The new (complete) messages look like this:
> `SQLSTATE[08006] [7] connection to server at "…" (…), port 5… failed: SSL error: sslv3 alert unexpected message (Connection: main, SQL: …`

That is, it still contains "SSL error: sslv3 alert unexpected message"
but there's now connection specific information before the SQLSTATE
prefix.

Since lost connection detection is based on exact string matching and
not regex, we're just removing the magic numbers in front and still
keep backwards compatibility.

I opened this PR against Laravel 10.x because we're still using and it
requires the fix there (we're in the progress moving to L11, but it still
takes time).

Thanks
  • Loading branch information
mfn authored Dec 8, 2024
1 parent 3dcbda2 commit bd0e7cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Database/DetectsLostConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ protected function causedByLostConnection(Throwable $e)
'Reason: Server is in script upgrade mode. Only administrator can connect at this time.',
'Unknown $curl_error_code: 77',
'SSL: Handshake timed out',
'SQLSTATE[08006] [7] SSL error: sslv3 alert unexpected message',
'SQLSTATE[08006] [7] unrecognized SSL error code:',
'SSL error: sslv3 alert unexpected message',
'unrecognized SSL error code:',
'SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it',
'SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',
'SQLSTATE[HY000] [2002] Network is unreachable',
Expand Down

0 comments on commit bd0e7cc

Please sign in to comment.