tursodatabase/turso · error · anyhow::Error
MVCC logical log frame checksum mismatch at offset
Error message
MVCC logical log frame checksum mismatch at offset {offset} What it means
Every frame carries a chained CRC32C: the running checksum is seeded from the header salt (initial_mvcc_log_crc) and each frame's trailer must store crc32c_append(running, frame_bytes_before_trailer). A mismatch means the frame bytes changed after write, or the chain was broken by reordering, rewriting, or interleaved writers. The scan aborts because every later frame would also fail.
Solutions
- Restore the log from a backup taken when it was consistent
- Regenerate the log and let clients resync via replace-base
- Guarantee single-writer access to the MVCC log and fsync frames before advancing the write position
Defensive patterns
Strategy: try-catch
Try / catch
match scan_mvcc_log(&log) {
Ok(snapshot) => serve(snapshot),
Err(err) if err.to_string().starts_with("MVCC logical log frame checksum mismatch") => {
warn!("chained CRC broken: {err}");
// everything after the break is untrusted: restore backup or regenerate
restore_or_rebuild()?
}
Err(err) => return Err(err),
} Prevention
- Enforce exactly one writer process per MVCC log (lock file or supervisor guarantee)
- fsync each frame before publishing its offset
- Snapshot/backup logs only while the writer is stopped
When it happens
Trigger: scan_mvcc_log reaches a frame whose stored trailer CRC differs from the chained expected value - e.g. a byte flipped inside the payload, a frame rewritten in place, or two processes appending concurrently so chains diverge.
Common situations: Disk-level bit rot; a crash mid-append followed by partial overwrite; concurrent sync-server instances sharing one log file; syncing a log copied while still being appended.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- MVCC logical log header checksum mismatch
- invalid MVCC logical log frame end magic at offset
- invalid MVCC logical log frame magic at offset
- invalid MVCC logical log header flags
- invalid MVCC logical log header length
AI-assisted analysis of tursodatabase/turso@492c4a71cd (2026-08-20).
Data as JSON: /api/errors/e003f672eece9051.
Report an issue: GitHub.
Appendix: source
Thrown at cli/sync_server.rs:1205
extension_size
} else {
0
};
let trailer_start = offset
.checked_add(header_size)
.and_then(|value| value.checked_add(payload_size))
.and_then(|value| value.checked_add(extension_size))
.ok_or_else(|| anyhow!("MVCC logical log frame offset overflow"))?;
let frame_end = trailer_start
.checked_add(MVCC_TX_TRAILER_SIZE)
.ok_or_else(|| anyhow!("MVCC logical log frame end overflow"))?;
if frame_end > log.len() {
return Ok(None);
}
let expected_crc = crc32c::crc32c_append(running_crc, &log[offset..trailer_start]);
let stored_crc = read_u32_le(log, trailer_start)?;
if stored_crc != expected_crc {
return Err(anyhow!(
"MVCC logical log frame checksum mismatch at offset {offset}"
));
}
let end_magic = read_u32_le(log, trailer_start + 4)?;
if end_magic != MVCC_TX_END_MAGIC {
return Err(anyhow!(
"invalid MVCC logical log frame end magic at offset {offset}"
));
}
Ok(Some((frame_end, stored_crc)))
}
fn read_u32_le(buf: &[u8], offset: usize) -> Result<u32> {
let bytes = buf
.get(offset..offset + 4)
.ok_or_else(|| anyhow!("buffer too short for u32 at offset {offset}"))?;
Ok(u32::from_le_bytes(bytes.try_into().unwrap()))
}View on GitHub (pinned to 492c4a71cd)