{"record":{"id":"d89f8f92d420b140","repo":"nautechsystems/nautilus_trader","slug":"database-is-not-initialized-so-we-cannot-bootstra","errorCode":null,"errorMessage":"Database is not initialized, so we cannot bootstrap the pool profiler from an RPC snapshot","messagePattern":"Database is not initialized, so we cannot bootstrap the pool profiler from an RPC snapshot","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/data/core.rs","lineNumber":1580,"sourceCode":"\n        Ok((profiler, false))\n    }\n\n    /// Bootstraps a pool profiler by reading liquidity topology from HyperSync and state from RPC.\n    ///\n    /// This mode avoids storing the full swap history. It streams Initialize, Mint, Burn, and\n    /// fee-protocol updates only, then hydrates the exact target block from the pool contract.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if database is not initialized, event streaming fails, or RPC hydration fails.\n    pub async fn bootstrap_pool_profiler_from_rpc_snapshot(\n        &mut self,\n        pool: &SharedPool,\n        to_block: u64,\n    ) -> anyhow::Result<(PoolProfiler, bool)> {\n        if self.cache.database.is_none() {\n            anyhow::bail!(\n                \"Database is not initialized, so we cannot bootstrap the pool profiler from an RPC snapshot\"\n            );\n        }\n\n        self.construct_pool_profiler_from_hypersync_rpc(\n            PoolProfiler::new(pool.clone()),\n            None,\n            to_block,\n        )\n        .await\n    }\n\n    /// Advances an RPC-hydrated profiler to a later checkpoint.\n    ///\n    /// The profiler must come from [`Self::bootstrap_pool_profiler_from_rpc_snapshot`] or an earlier\n    /// call to this method. This keeps one command incremental without trusting an unproven stored\n    /// snapshot as the topology source.\n    ///","sourceCodeStart":1562,"sourceCodeEnd":1598,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/data/core.rs#L1562-L1598","documentation":"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.","triggerScenarios":"Calling bootstrap_pool_profiler_from_rpc_snapshot on a client whose cache.database is None.","commonSituations":"Same as error 396: in-memory cache for tests, DB config omitted, or DB init failed earlier.","solutions":["Initialize the cache with a database before calling this method","Recreate the data client with database enabled","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"],"exampleFix":"// before\n// cache built without db; bootstrap_pool_profiler_from_rpc_snapshot(...) errors\n// after\nlet cache = Cache::new(db_config.with_database(\"/data/cache.db\"));\nclient.bootstrap_pool_profiler_from_rpc_snapshot(&pool, to_block).await?;","handlingStrategy":"validation","validationCode":"ensure!(client.cache_database().is_some(), \"rpc snapshot bootstrap requires a configured database\");\nclient.bootstrap_pool_profiler_from_rpc_snapshot(&pool, to_block).await?;","typeGuard":"fn db_ready(c: &BlockchainDataClient) -> bool { c.cache_database().is_some() }","tryCatchPattern":"match client.bootstrap_pool_profiler_from_rpc_snapshot(&pool, to_block).await {\n    Err(e) if e.to_string().contains(\"Database is not initialized\") => {\n        log::error!(\"enable cache.database to use RPC snapshot bootstrap\");\n    }\n    r => r?,\n}","preventionTips":["Initialize the database before any bootstrap_* call","Add an startup assertion that database config exists when snapshot bootstrap is used","Keep test fixtures using a real (temp) database rather than None"],"tags":["database","profiler","rpc","snapshot"],"backgroundTag":"missing-required-config-field","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}