mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
Make PgListener recover from UnexpectedEof (#2684)
This is often encountered when the host the db is on is restarted. For example, a reboot of AWS Aurora causes 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.
This commit is contained in:
parent
b85b72355e
commit
ab0d10d935
1 changed files with 4 additions and 1 deletions
|
@ -262,7 +262,10 @@ impl PgListener {
|
|||
|
||||
// The connection is dead, ensure that it is dropped,
|
||||
// update self state, and loop to try again.
|
||||
Err(Error::Io(err)) if err.kind() == io::ErrorKind::ConnectionAborted => {
|
||||
Err(Error::Io(err))
|
||||
if (err.kind() == io::ErrorKind::ConnectionAborted
|
||||
|| err.kind() == io::ErrorKind::UnexpectedEof) =>
|
||||
{
|
||||
self.buffer_tx = self.connection().await?.stream.notifications.take();
|
||||
self.connection = None;
|
||||
|
||||
|
|
Loading…
Reference in a new issue