nautechsystems/nautilus_trader · error

Database is not initialized, so we cannot bootstrap the pool

Error message

Database is not initialized, so we cannot bootstrap the pool profiler from an RPC snapshot

What it means

bootstrap_pool_profiler_from_rpc_snapshot rebuilds a pool profiler using HyperSync/RPC event data with database-backed checkpoints. Without a database in the cache, the snapshot bootstrap cannot persist/verify watermarks, so it fails before doing work.

Source

Thrown at crates/adapters/blockchain/src/data/core.rs:1580

        Ok((profiler, false))
    }

    /// Bootstraps a pool profiler by reading liquidity topology from HyperSync and state from RPC.
    ///
    /// This mode avoids storing the full swap history. It streams Initialize, Mint, Burn, and
    /// fee-protocol updates only, then hydrates the exact target block from the pool contract.
    ///
    /// # Errors
    ///
    /// Returns an error if database is not initialized, event streaming fails, or RPC hydration fails.
    pub async fn bootstrap_pool_profiler_from_rpc_snapshot(
        &mut self,
        pool: &SharedPool,
        to_block: u64,
    ) -> anyhow::Result<(PoolProfiler, bool)> {
        if self.cache.database.is_none() {
            anyhow::bail!(
                "Database is not initialized, so we cannot bootstrap the pool profiler from an RPC snapshot"
            );
        }

        self.construct_pool_profiler_from_hypersync_rpc(
            PoolProfiler::new(pool.clone()),
            None,
            to_block,
        )
        .await
    }

    /// Advances an RPC-hydrated profiler to a later checkpoint.
    ///
    /// The profiler must come from [`Self::bootstrap_pool_profiler_from_rpc_snapshot`] or an earlier
    /// call to this method. This keeps one command incremental without trusting an unproven stored
    /// snapshot as the topology source.
    ///

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Initialize the cache with a database before calling this method
  2. Recreate the data client with database enabled
  3. Fall back to bootstrap_latest_pool_profiler only if it fits (it also requires a DB), or construct the profiler incrementally via advance_pool_profiler_from_rpc_snapshot without DB-dependent bootstrap

Example fix

// before
// cache built without db; bootstrap_pool_profiler_from_rpc_snapshot(...) errors
// after
let cache = Cache::new(db_config.with_database("/data/cache.db"));
client.bootstrap_pool_profiler_from_rpc_snapshot(&pool, to_block).await?;
Defensive patterns

Strategy: validation

Validate before calling

ensure!(client.cache_database().is_some(), "rpc snapshot bootstrap requires a configured database");
client.bootstrap_pool_profiler_from_rpc_snapshot(&pool, to_block).await?;

Type guard

fn db_ready(c: &BlockchainDataClient) -> bool { c.cache_database().is_some() }

Try / catch

match client.bootstrap_pool_profiler_from_rpc_snapshot(&pool, to_block).await {
    Err(e) if e.to_string().contains("Database is not initialized") => {
        log::error!("enable cache.database to use RPC snapshot bootstrap");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling bootstrap_pool_profiler_from_rpc_snapshot on a client whose cache.database is None.

Common situations: Same as error 396: in-memory cache for tests, DB config omitted, or DB init failed earlier.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/d89f8f92d420b140. Report an issue: GitHub.