From 1ada97108ea8dc3c58f90255d8515f493cac56b9 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Thu, 10 Aug 2023 17:39:37 +0300
Subject: [PATCH] fix: used to fail to start when io error happened

---
 src/lib.rs | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index bd108eac9c..af90ef51c3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -513,12 +513,17 @@ fn start_join(args: &args::Run, instance_address: String) {
                 break resp;
             }
             Err(TntError::Tcp(e)) => {
-                tlog!(Warning, "join request failed: {e}, retry...");
+                tlog!(Warning, "join request failed: {e}, retrying...");
+                fiber::sleep(timeout.saturating_sub(now.elapsed()));
+                continue;
+            }
+            Err(TntError::IO(e)) => {
+                tlog!(Warning, "join request failed: {e}, retrying...");
                 fiber::sleep(timeout.saturating_sub(now.elapsed()));
                 continue;
             }
             Err(e) => {
-                tlog!(Error, "join request failed: {e}");
+                tlog!(Error, "join request failed: {e}, shutting down...");
                 std::process::exit(-1);
             }
         }
@@ -654,6 +659,11 @@ fn postjoin(args: &args::Run, storage: Clusterwide, raft_storage: RaftSpaceAcces
                 fiber::sleep(timeout.saturating_sub(now.elapsed()));
                 continue;
             }
+            Err(timeout::Error::Failed(TntError::IO(e))) => {
+                tlog!(Warning, "failed to activate myself: {e}, retrying...");
+                fiber::sleep(timeout.saturating_sub(now.elapsed()));
+                continue;
+            }
             Err(e) => {
                 tlog!(Error, "failed to activate myself: {e}, shutting down...");
                 std::process::exit(-1);
-- 
GitLab