{"record":{"id":"409a282e90d395e0","repo":"tursodatabase/turso","slug":"buffer-not-loaded","errorCode":null,"errorMessage":"buffer not loaded","messagePattern":"buffer not loaded","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/storage/pager.rs","lineNumber":164,"sourceCode":"        /// The actual page data buffer. None if not loaded.\n        buffer: Option<Arc<Buffer>>,\n        /// Start and length of the bytes of `buffer`, kept next to it so a page\n        /// read does not go through the `Option`, the `Arc` and the `Buffer`\n        /// variant on every access. Null and 0 while `buffer` is `None`.\n        data_ptr: *mut u8,\n        data_len: usize,\n        /// Overflow cells during btree operations\n        pub overflow_cells: crate::alloc::Vec<OverflowCell>,\n    }\n\n    // SAFETY: data_ptr and data_len only cache the address and length of the\n    // bytes owned by `buffer`, an `Arc<Buffer>` that is itself Send and Sync, so\n    // PageInner can cross threads exactly as it could before the cache existed.\n    unsafe impl Send for PageInner {}\n    unsafe impl Sync for PageInner {}\n\n    // Methods moved from PageContent - these provide btree page access\n    impl PageInner {\n        /// Creates a new PageInner from an Arc<Buffer>.\n        pub fn new(buffer: Arc<Buffer>) -> Self {\n            let mut inner = Self::unloaded(0);\n            inner.set_buffer(buffer);\n            inner\n        }\n\n        /// Creates a new PageInner with an owned buffer.\n        pub fn from_buffer(buffer: Buffer) -> Self {\n            Self::new(Arc::new(buffer))\n        }\n\n        /// Creates a PageInner with no buffer loaded.\n        pub fn unloaded(id: usize) -> Self {\n            Self {\n                flags: AtomicUsize::new(0),\n                id,\n                header_offset: Self::header_offset_of(id),","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/tursodatabase/turso/blob/8d4a589f8d13ac184700d2a8f724f27e1995be3b/core/storage/pager.rs#L146-L182","documentation":"Page::as_ptr() (core/storage/pager.rs) hands out a mutable slice of the page buffer and expects buffer to be Some (\"buffer not loaded\"). Pages whose buffer was taken during eviction or never loaded have buffer=None; touching their contents through get_contents()/as_ptr() panics.","triggerScenarios":"Calling get_contents()/as_ptr() on a PageRef that was not (re)loaded - e.g. a page re-fetched from the cache after eviction without return_if_locked_maybe_load!, or a dirty page whose backing WAL frame was truncated by savepoint rollback.","commonSituations":"Custom btree/pager code skipping the load macros, heavy cache pressure evicting pages mid-operation, engine regressions in pin/reload discipline. The commit path already carries an explicit unloaded-page guard for this shape.","solutions":["Always acquire pages through pager.read_page() / return_if_locked_maybe_load! so the buffer is loaded before contents are touched","Check page.is_loaded() before accessing contents in any custom code","Treat occurrences inside engine paths as bugs - report them with a reproduction","Reduce cache pressure (larger page cache) to avoid eviction windows"],"exampleFix":"// before\nlet contents = page.get_contents(); // panics if evicted: buffer is None\nlet ptr = contents.as_ptr();\n\n// after\nif !page.is_loaded() {\n    return Err(LimboError::InternalError(format!(\"page {} buffer not loaded\", page.get().id)));\n}\nlet contents = page.get_contents();","handlingStrategy":"validation","validationCode":"// Before touching page contents in custom code over the pager/btree APIs:\nif !page.is_loaded() {\n    return Err(LimboError::InternalError(format!(\n        \"page {} buffer not loaded; re-read via pager.read_page()\", page.get().id\n    )));\n}","typeGuard":"fn is_page_loaded(page: &PageRef) -> bool {\n    page.is_loaded()\n}","tryCatchPattern":null,"preventionTips":["Acquire pages only through pager.read_page()/return_if_locked_maybe_load! which guarantee a loaded buffer","Never cache PageRefs across operations that can evict (cache pressure, savepoint rollback)","Check is_loaded() in debug assertions in custom storage code","Report engine-path occurrences upstream - the commit path already guards this shape explicitly"],"tags":["pager","page-buffer","eviction","panic"],"backgroundTag":"page-buffer-not-loaded","analyzedSha":"8d4a589f8d13ac184700d2a8f724f27e1995be3b","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}