From 64340fe16dbfbe47dad236b6abfb5c2e40f10267 Mon Sep 17 00:00:00 2001 From: lowit Date: Thu, 30 Jan 2025 12:50:19 +0300 Subject: [PATCH] feat: remove sleep for repeated cluster runs If we sleep in repeated cluster runs (after first cluster initialization), then instances can not get quorum and they can not start. --- src/commands/run.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands/run.rs b/src/commands/run.rs index dc8ce8e..a5c8a56 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -383,6 +383,8 @@ pub fn cluster(params: &Params) -> Result> { info!("Running the cluster..."); + let is_clean_run = !params.data_dir.join("cluster").exists(); + let mut picodata_processes = vec![]; let first_instance_bin_port = 3001; @@ -404,8 +406,10 @@ pub fn cluster(params: &Params) -> Result> { picodata_processes.push(pico_instance); - // TODO: check is started by logs or iproto - thread::sleep(Duration::from_secs(5)); + if is_clean_run { + // TODO: check is started by logs or iproto + thread::sleep(Duration::from_secs(5)); + } info!("i{instance_id} - started"); } @@ -414,6 +418,11 @@ pub fn cluster(params: &Params) -> Result> { if !params.disable_plugin_install { info!("Enabling plugins..."); + if !is_clean_run { + // TODO: check is started by logs or iproto + thread::sleep(Duration::from_secs(5)); + } + let result = enable_plugins(&topology, ¶ms.data_dir, ¶ms.picodata_path); if let Err(e) = result { for process in &mut picodata_processes {