{"record":{"id":"dbe6c6d021d52d8f","repo":"nautechsystems/nautilus_trader","slug":"database-is-not-initialized-so-we-cannot-properly","errorCode":null,"errorMessage":"Database is not initialized, so we cannot properly bootstrap the latest pool profiler","messagePattern":"Database is not initialized, so we cannot properly bootstrap the latest pool profiler","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/data/core.rs","lineNumber":1482,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if database is not initialized or event processing fails.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the database reference is unavailable.\n    pub async fn bootstrap_latest_pool_profiler(\n        &mut self,\n        pool: &SharedPool,\n        to_block: Option<u64>,\n    ) -> anyhow::Result<(PoolProfiler, bool)> {\n        log::debug!(\n            \"Bootstrapping latest pool profiler for pool {}\",\n            pool.address\n        );\n\n        if self.cache.database.is_none() {\n            anyhow::bail!(\n                \"Database is not initialized, so we cannot properly bootstrap the latest pool profiler\"\n            );\n        }\n\n        let to_block = match to_block {\n            Some(block) => block,\n            None => self.hypersync_client.current_block().await,\n        };\n        let (mut profiler, from_position) = self\n            .seed_pool_profiler_from_latest_snapshot(pool, to_block)\n            .await?;\n\n        // If we don't have never synced pool events, proceed with faster\n        // construction of pool profiler from hypersync and RPC, where we\n        // dont need syncing of pool events and fetching it from database\n        if self\n            .cache\n            .database","sourceCodeStart":1464,"sourceCodeEnd":1500,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/data/core.rs#L1464-L1500","documentation":"bootstrap_latest_pool_profiler replays historical pool events and persists state, which requires the cache's database. When cache.database is None (no DB configured), bootstrap cannot produce a correct profiler, so it fails explicitly instead of returning a profiler without history.","triggerScenarios":"Calling bootstrap_latest_pool_profiler on a client whose cache was constructed without a database (in-memory cache only).","commonSituations":"Running with an in-memory/temporary cache for quick tests; DB config omitted; DB failed to open earlier so database stayed None.","solutions":["Configure and initialize the cache database (e.g. RocksDB/SQLite path) before bootstrapping","Recreate the data client with database enabled","If no persistence is desired, avoid bootstrap and construct the profiler from an RPC snapshot or from scratch"],"exampleFix":"// before\nlet cache = Cache::new(memory_config); // database: None\n// after\nlet cache = Cache::new(db_config.with_database(\"/data/cache.db\"));","handlingStrategy":"validation","validationCode":"if client.cache_database().is_none() {\n    return Err(anyhow::anyhow!(\"bootstrap requires a cache database; configure one first\"));\n}\nclient.bootstrap_latest_pool_profiler(&pool, None).await?;","typeGuard":"fn has_database(c: &BlockchainDataClient) -> bool { c.cache_database().is_some() }","tryCatchPattern":"match client.bootstrap_latest_pool_profiler(&pool, to_block).await {\n    Err(e) if e.to_string().contains(\"Database is not initialized\") => {\n        log::error!(\"configure cache.database before bootstrapping\");\n    }\n    r => r?,\n}","preventionTips":["Enable the cache database in all profiles that use bootstrap APIs","Fail fast at startup if database config is missing","Document that in-memory caches cannot bootstrap profilers"],"tags":["database","bootstrap","profiler","initialization"],"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-14T00:17:10.932Z"}