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:
Peter Hamilton 2023-10-17 16:10:53 -07:00 committed by GitHub
parent b85b72355e
commit ab0d10d935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;