{"record":{"id":"189011ba319631c9","repo":"tursodatabase/turso","slug":"database-page-is-missing-from-replace-base-snap","errorCode":null,"errorMessage":"database page {} is missing from replace-base snapshot","messagePattern":"database page (.+?) is missing from replace-base snapshot","errorType":"http","errorClass":null,"httpStatus":500,"severity":"critical","filePath":"cli/sync_server.rs","lineNumber":862,"sourceCode":"\n    #[allow(clippy::type_complexity)]\n    fn read_replace_base_pages(&self) -> Result<(u64, Vec<(u64, Vec<u8>)>)> {\n        let conn = self.conn.lock().unwrap();\n        let wal_state = conn.wal_state()?;\n        let frame_watermark = Some(wal_state.max_frame);\n        let db_size = current_snapshot_db_size_pages(&conn, wal_state.max_frame)?;\n        let pages_capacity = usize::try_from(db_size)\n            .map_err(|_| anyhow!(\"database page count does not fit usize: {db_size}\"))?;\n        let mut pages = Vec::with_capacity(pages_capacity);\n\n        for page_no in 1..=db_size {\n            let page_no_u32 = u32::try_from(page_no)\n                .map_err(|_| anyhow!(\"database page number does not fit u32: {page_no}\"))?;\n            let mut page = vec![0; PAGE_SIZE];\n            let found =\n                conn.try_wal_watermark_read_page(page_no_u32, &mut page, frame_watermark)?;\n            if !found {\n                return Err(anyhow!(\n                    \"database page {} is missing from replace-base snapshot\",\n                    page_no\n                ));\n            }\n            pages.push((page_no - 1, page));\n        }\n\n        Ok((db_size, pages))\n    }\n}\n\nstruct HttpResponse {\n    status: u16,\n    content_type: String,\n    body: Vec<u8>,\n}\n\nstruct MvccLogSnapshot {","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/cli/sync_server.rs#L844-L880","documentation":"When serving a replace-base (full snapshot) response, the server walks pages 1..=db_size reading each through the WAL at the max_frame watermark. try_wal_watermark_read_page returning false means a page the header says exists is invisible at that watermark, i.e. the WAL view is inconsistent. The constructor calls wal_auto_actions_disable() precisely to keep this watermark stable, so hitting the error means something checkpointed, reset, or truncated the WAL concurrently, the WAL is damaged, or the watermark read has a bug; the server refuses rather than emit a silently corrupt snapshot.","triggerScenarios":"An external process (sqlite3 CLI checkpoint, another tursodb connection, a second sync server) checkpointing or resetting the WAL mid-pull; deleting or truncating the -wal file while the server runs; WAL corruption after a crash; an engine bug in try_wal_watermark_read_page.","commonSituations":"Mixing CLI tools and the sync server on one database file; running two experiments against the same db; crash-damaged WAL files.","solutions":["Stop every other writer/checkpointer on the .db/.wal files while the sync server is running.","Restart the sync server so it re-establishes a stable WAL watermark, then retry the pull.","Run integrity checks on the database and WAL; if files are damaged, rebuild the server db and re-bootstrap clients.","If it reproduces with a single isolated server, file a tursodb bug attaching the .db, -wal, and .db-log files."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"On 500 'database page N is missing from replace-base snapshot': stop all other processes touching the .db/.wal, restart the sync server to re-establish a stable WAL watermark, then retry the pull. If it recurs on an isolated server, treat the files as damaged, rebuild, and re-bootstrap clients.","preventionTips":["Give the sync server exclusive access: never run sqlite3 CLI checkpoints or other writers against its database.","Run at most one sync server per database file.","Do not re-enable WAL auto actions on the server connection: wal_auto_actions_disable() is what keeps the watermark read consistent."],"tags":["sync","wal","snapshot","corruption","pages"],"backgroundTag":"snapshot-consistency-error","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}