Skip to content

Commit 56167d0

Browse files
committed
Make PgListener recover from UnexpectedEof
This is often encountered when the host the db is on is restarted. For example, a reboot of AWS Aurora cauases this. If we don't handle this properly the PgListeners are stuck in an erroring state, even when the DB is back online. By catching it here, we will reconnect when it is (eventually) back online.
1 parent d0fbe7f commit 56167d0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sqlx-postgres/src/listener.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ impl PgListener {
262262

263263
// The connection is dead, ensure that it is dropped,
264264
// update self state, and loop to try again.
265-
Err(Error::Io(err)) if err.kind() == io::ErrorKind::ConnectionAborted => {
265+
Err(Error::Io(err))
266+
if (err.kind() == io::ErrorKind::ConnectionAborted
267+
|| err.kind() == io::ErrorKind::UnexpectedEof) =>
268+
{
266269
self.buffer_tx = self.connection().await?.stream.notifications.take();
267270
self.connection = None;
268271

0 commit comments

Comments
 (0)