{"record":{"id":"5c31028f6b4eace9","repo":"tursodatabase/turso","slug":"pool-not-initialized","errorCode":null,"errorMessage":"Pool not initialized","messagePattern":"Pool not initialized","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/storage/buffer_pool.rs","lineNumber":285,"sourceCode":"            .as_ref()\n            .and_then(|arena| Arena::try_alloc(arena, db_page_size))\n            .unwrap_or_else(|| Buffer::new_temporary(db_page_size))\n    }\n\n    fn get_wal_frame_buffer(&mut self) -> Buffer {\n        let len = self.get_db_page_size() + WAL_FRAME_HEADER_SIZE;\n        self.wal_frame_arena\n            .as_ref()\n            .and_then(|wal_arena| Arena::try_alloc(wal_arena, len))\n            .unwrap_or_else(|| Buffer::new_temporary(len))\n    }\n\n    /// Allocate a new arena for the pool to use\n    fn init_arenas(&mut self) -> crate::Result<()> {\n        let db_page_size = self.get_db_page_size();\n        let arena_size = self.arena_size;\n\n        let io = self.io.as_ref().expect(\"Pool not initialized\").clone();\n\n        // Create regular page arena\n        match Arena::new(db_page_size, arena_size, &io) {\n            Ok(arena) => {\n                tracing::trace!(\n                    \"added arena {} with size {} MB and slot size {}\",\n                    arena.id,\n                    arena_size / (1024 * 1024),\n                    db_page_size\n                );\n                self.page_arena = Some(Arc::new(arena));\n            }\n            Err(e) => {\n                tracing::error!(\"Failed to create arena: {:?}\", e);\n                return Err(LimboError::InternalError(format!(\n                    \"Failed to create arena: {e}\",\n                )));\n            }","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/core/storage/buffer_pool.rs#L267-L303","documentation":"PoolInner::init_arenas() (core/storage/buffer_pool.rs) requires self.io to have been stored by BufferPool::begin_init(io, arena_size). The expect(\"Pool not initialized\") fires when finalize_with_page_size(page_size) triggers arena creation on a pool that was never handed an Arc<dyn IO> - the arena needs the IO handle to register its buffers.","triggerScenarios":"Calling finalize_with_page_size() (directly or via the Database open flow) on a BufferPool constructed through a path that skips begin_init - custom embedder code or unit tests building the pool manually without an IO implementation.","commonSituations":"Embedding turso core directly in tests, wiring a custom IO driver after pool creation, API changes between versions where pool construction was refactored.","solutions":["Create the pool with BufferPool::begin_init(&io, arena_size) so the IO handle is stored before any finalize call","Call finalize_with_page_size(page_size) only after the Database open sequence has run begin_init","If constructing pools manually in tests, pass the same Arc<dyn IO> you use for the database file"],"exampleFix":"// before\nlet pool = make_pool_without_io(); // constructed without begin_init\npool.finalize_with_page_size(4096)?; // panics: init_arenas() has no io\n\n// after\nlet pool = BufferPool::begin_init(&io, arena_size); // stores Arc<dyn IO>\npool.finalize_with_page_size(4096)?; // init_arenas() succeeds","handlingStrategy":"validation","validationCode":"// When wiring the pool manually, always create it through begin_init so the\n// IO handle is stored before finalize_with_page_size can run:\nlet pool = BufferPool::begin_init(&io, arena_size); // io: Arc<dyn IO>\npool.finalize_with_page_size(page_size)?; // now init_arenas() finds self.io","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never construct BufferPool instances outside the documented begin_init/finalize_with_page_size flow","Pass the same Arc<dyn IO> used for the database file into begin_init","Add a debug_assert in embedder code that the pool came from begin_init before calling finalize"],"tags":["buffer-pool","initialization","setup","panic"],"backgroundTag":"resource-pool-not-initialized","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}