pub async fn maybe_initialize_server(&self) {
        // Explicit scope to help async generator
        let (wipe_catalog_on_error, skip_replay_and_seek_instead, config) = {
            let state = self.stage.upgradable_read();
            match &*state {
                ServerStage::InitReady {
                    wipe_catalog_on_error,
                    skip_replay_and_seek_instead,
                    config,
                    last_error,
                } => {
                    let config = Arc::clone(config);
                    let last_error = last_error.clone();
                    let wipe_catalog_on_error = *wipe_catalog_on_error;
                    let skip_replay_and_seek_instead = *skip_replay_and_seek_instead;

                    // Mark the server as initializing and drop lock

                    let mut state = RwLockUpgradableReadGuard::upgrade(state);
                    *state = ServerStage::Initializing {
                        config: Arc::clone(&config),
                        wipe_catalog_on_error,
                        last_error,
                    };
                    (wipe_catalog_on_error, skip_replay_and_seek_instead, config)
                }
                _ => return,
            }
        };

        let init_result = init::initialize_server(
            Arc::clone(&config),
            wipe_catalog_on_error,
            skip_replay_and_seek_instead,
        )
        .await;
        let new_stage = match init_result {
            // Success -> move to next stage
            Ok(results) => {
                info!(server_id=%config.server_id(), "server initialized");
                ServerStage::Initialized {
                    config,
                    database_errors: results
                        .into_iter()
                        .filter_map(|(name, res)| Some((name.to_string(), Arc::new(res.err()?))))
                        .collect(),
                }
            }
            // Error -> return to InitReady
            Err(err) => {
                error!(%err, "error during server init");
                ServerStage::InitReady {
                    wipe_catalog_on_error,
                    skip_replay_and_seek_instead,
                    config,
                    last_error: Some(Arc::new(err)),
                }
            }
        };

        *self.stage.write() = new_stage;
    }
/// Loads the database configurations based on the databases in the
/// object store. Any databases in the config already won't be
/// replaced.
///
/// This requires the serverID to be set.
///
/// It will be a no-op if the configs are already loaded and the server is ready.
Loads the database configurations based on the databases in the
object store. Any databases in the config already won't be
replaced.

This requires the serverID to be set.

It will be a no-op if the configs are already loaded and the server is ready.
Loads the database configurations based on the databases in the object store . Any databases in the config already won ' t be replaced . This requires the serverID to be set . It will be a no - op if the configs are already loaded and the server is ready .
pub async fn maybe_initialize_server(&self) {
        // Explicit scope to help async generator
        let (wipe_catalog_on_error, skip_replay_and_seek_instead, config) = {
            let state = self.stage.upgradable_read();
            match &*state {
                ServerStage::InitReady {
                    wipe_catalog_on_error,
                    skip_replay_and_seek_instead,
                    config,
                    last_error,
                } => {
                    let config = Arc::clone(config);
                    let last_error = last_error.clone();
                    let wipe_catalog_on_error = *wipe_catalog_on_error;
                    let skip_replay_and_seek_instead = *skip_replay_and_seek_instead;
                    // Mark the server as initializing and drop lock
                    let mut state = RwLockUpgradableReadGuard::upgrade(state);
                    *state = ServerStage::Initializing {
                        config: Arc::clone(&config),
                        wipe_catalog_on_error,
                        last_error,
                    };
                    (wipe_catalog_on_error, skip_replay_and_seek_instead, config)
                }
                _ => return,
            }
        };
        let init_result = init::initialize_server(
            Arc::clone(&config),
            wipe_catalog_on_error,
            skip_replay_and_seek_instead,
        )
        .await;
        let new_stage = match init_result {
            // Success -> move to next stage
            Ok(results) => {
                info!(server_id=%config.server_id(), "server initialized");
                ServerStage::Initialized {
                    config,
                    database_errors: results
                        .into_iter()
                        .filter_map(|(name, res)| Some((name.to_string(), Arc::new(res.err()?))))
                        .collect(),
                }
            }
            // Error -> return to InitReady
            Err(err) => {
                error!(%err, "error during server init");
                ServerStage::InitReady {
                    wipe_catalog_on_error,
                    skip_replay_and_seek_instead,
                    config,
                    last_error: Some(Arc::new(err)),
                }
            }
        };
        *self.stage.write() = new_stage;
    }
pub async fn maybe_initialize_server ( & self ) { // Explicit scope to help async generator let ( wipe_catalog_on_error , skip_replay_and_seek_instead , config ) = { let state = self . stage . upgradable_read ( ) ; match & * state { ServerStage :: InitReady { wipe_catalog_on_error , skip_replay_and_seek_instead , config , last_error , } => { let config = Arc :: clone ( config ) ; let last_error = last_error . clone ( ) ; let wipe_catalog_on_error = * wipe_catalog_on_error ; let skip_replay_and_seek_instead = * skip_replay_and_seek_instead ; // Mark the server as initializing and drop lock let mut state = RwLockUpgradableReadGuard :: upgrade ( state ) ; * state = ServerStage :: Initializing { config : Arc :: clone ( & config ) , wipe_catalog_on_error , last_error , } ; ( wipe_catalog_on_error , skip_replay_and_seek_instead , config ) } _ => return , } } ; let init_result = init :: initialize_server ( Arc :: clone ( & config ) , wipe_catalog_on_error , skip_replay_and_seek_instead , ) . await ; let new_stage = match init_result { // Success -> move to next stage Ok ( results ) => { info ! ( server_id config server_id ( ) " " ) ; ServerStage :: Initialized { config , database_errors : results . into_iter ( ) . filter_map ( | ( name , res ) | Some ( ( name . to_string ( ) , Arc :: new ( res . err ( ) ? ) ) ) ) . collect ( ) , } } // Error -> return to InitReady Err ( err ) => { error ! ( err " " ) ; ServerStage :: InitReady { wipe_catalog_on_error , skip_replay_and_seek_instead , config , last_error : Some ( Arc :: new ( err ) ) , } } } ; * self . stage . write ( ) = new_stage ; }
Loads the database configurations based on the databases in the
object store.
Loads the database configurations based on the databases in the object store .
&self
&self