{"record":{"id":"96f42920d8ab5471","repo":"tursodatabase/turso","slug":"invalid-mvcc-logical-log-magic","errorCode":null,"errorMessage":"invalid MVCC logical log magic","messagePattern":"invalid MVCC logical log magic","errorType":"http","errorClass":null,"httpStatus":500,"severity":"critical","filePath":"cli/sync_server.rs","lineNumber":1100,"sourceCode":"        running_crc = frame_crc;\n        offset = frame_end;\n        crc_by_offset.push((offset as u64, running_crc));\n    }\n\n    Ok(MvccLogSnapshot {\n        end_offset: offset as u64,\n        crc_by_offset,\n    })\n}\n\nfn is_nonportable_mvcc_log_error(err: &anyhow::Error) -> bool {\n    let message = err.to_string();\n    message.starts_with(\"unsupported MVCC logical log version \")\n}\n\nfn validate_mvcc_log_header(log: &[u8]) -> Result<()> {\n    if read_u32_le(log, 0)? != MVCC_LOG_MAGIC {\n        return Err(anyhow!(\"invalid MVCC logical log magic\"));\n    }\n    if log[4] != MVCC_LOG_VERSION {\n        return Err(anyhow!(\"unsupported MVCC logical log version {}\", log[4]));\n    }\n    if log[5] & 0b1111_1110 != 0 {\n        return Err(anyhow!(\"invalid MVCC logical log header flags\"));\n    }\n    let header_len = u16::from_le_bytes([log[6], log[7]]) as usize;\n    if header_len != MVCC_LOG_HEADER_SIZE {\n        return Err(anyhow!(\n            \"invalid MVCC logical log header length: {header_len}\"\n        ));\n    }\n    if log[MVCC_LOG_HEADER_RESERVED_START..MVCC_LOG_HEADER_CRC_START]\n        .iter()\n        .any(|byte| *byte != 0)\n    {\n        return Err(anyhow!(","sourceCodeStart":1082,"sourceCodeEnd":1118,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/cli/sync_server.rs#L1082-L1118","documentation":"validate_mvcc_log_header checked the first 4 bytes of the .db-log file against MVCC_LOG_MAGIC and they do not match. The file at the logical-log path is simply not an MVCC logical log: a wrong or foreign file, garbage content, or a log written by an incompatible format/tool.","triggerScenarios":"A stale or unrelated file occupies <db>.db-log (rename/copy mistake); the log format changed between builds; the first bytes were corrupted (bit rot, partial overwrite); any logical pull then fails header validation.","commonSituations":"Reusing paths across server versions; accidentally pointing two databases at colliding .db-log names; files mangled by tooling or editors.","solutions":["Confirm the .db-log file was produced by this server build for this exact database","Remove the invalid log and let the server regenerate it, forcing clients to re-bootstrap","Restore the db and .db-log pair from a consistent backup"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// pre-flight magic check before serving logical pulls\nlet mut head = [0u8; 4];\nstd::fs::File::open(&log_path)?.read_exact(&mut head)?;\nif head != MVCC_LOG_MAGIC.to_le_bytes() {\n    return Err(anyhow!(\"file at {} is not an MVCC logical log\", log_path.display()));\n}","typeGuard":null,"tryCatchPattern":"match scan_mvcc_log(&log_bytes) {\n    Ok(snapshot) => snapshot,\n    Err(e) if e.to_string() == \"invalid MVCC logical log magic\" => {\n        // wrong file at the .db-log path: remove, regenerate, and re-bootstrap clients\n        std::fs::remove_file(&log_path)?;\n        regenerate_logical_log()?;\n        scan_mvcc_log(&std::fs::read(&log_path)?)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Give each database a unique path so .db-log names cannot collide","After server upgrades, regenerate or verify the logical log instead of reusing old files","Restore db and .db-log together from a consistent backup"],"tags":["mvcc","logical-log","magic","file-format","sync-server"],"backgroundTag":"invalid-file-magic","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}