From 939281101e37426de255e191e5b15257805a4a81 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 17 Mar 2021 23:35:09 +0200 Subject: [PATCH] page server: retry WAL streaming connection on error. --- src/walreceiver.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/walreceiver.rs b/src/walreceiver.rs index 8806a84d23..9d44090229 100644 --- a/src/walreceiver.rs +++ b/src/walreceiver.rs @@ -1,5 +1,6 @@ use tokio_stream::StreamExt; use tokio::runtime; +use tokio::time::{sleep, Duration}; use crate::waldecoder::WalStreamDecoder; use crate::page_cache; @@ -23,7 +24,13 @@ pub fn thread_main() { println!("Starting WAL receiver"); runtime.block_on( async { - let _unused = walreceiver_main().await; + loop { + let _res = walreceiver_main().await; + + // TODO: print/log the error + println!("WAL streaming connection failed, retrying in 5 seconds..."); + sleep(Duration::from_secs(5)).await; + } }); } @@ -109,6 +116,5 @@ pub async fn walreceiver_main() -> Result<(), Error> { _ => (), } } - return Ok(()); }