{"record":{"id":"e4b386a0f6b126fe","repo":"benbjohnson/litestream","slug":"cannot-verify-wal-state-w","errorCode":null,"errorMessage":"cannot verify wal state: %w","messagePattern":"cannot verify wal state: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"db.go","lineNumber":1378,"sourceCode":"\t// This avoids using file size which may include stale frames with old salt\n\t// values after a checkpoint. See issue #997.\n\torigWALSize := exec.state.lastSyncedWALOffset\n\tif origWALSize == 0 {\n\t\t// First sync - use file size as fallback\n\t\tvar err error\n\t\torigWALSize, err = db.walFileSize()\n\t\tif err != nil {\n\t\t\treturn syncResult{}, fmt.Errorf(\"stat wal before sync: %w\", err)\n\t\t}\n\t}\n\n\t// Verify our last sync matches the current state of the WAL.\n\t// This ensures that the last sync position of the real WAL hasn't\n\t// been overwritten by another process.\n\tdb.setSyncDiagPhase(diagPhaseVerify)\n\tinfo, err := db.verifyWithExecutor(ctx, exec)\n\tif err != nil {\n\t\treturn syncResult{}, fmt.Errorf(\"cannot verify wal state: %w\", err)\n\t}\n\n\tdb.setSyncDiagPhase(diagPhaseSyncLTX, func(s *diagState) {\n\t\ts.txID = exec.pos.TXID + 1\n\t\ts.snapshotting = info.snapshotting\n\t\ts.reason = info.reason\n\t\ts.lastSyncedWALOffset = exec.state.lastSyncedWALOffset\n\t})\n\tresult, err := db.sync(ctx, checkpointing, exec, info, maxSyncWALBytes)\n\tif err != nil {\n\t\treturn syncResult{}, fmt.Errorf(\"sync: %w\", err)\n\t}\n\n\tresult.origWALSize = origWALSize\n\treturn result, nil\n}\n\n// checkpointIfNeeded performs a checkpoint based on configured thresholds.","sourceCodeStart":1360,"sourceCodeEnd":1396,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/db.go#L1360-L1396","documentation":"verifyWithExecutor failed while checking that the WAL has not been overwritten by another process since the last sync (salt/txid verification). A mismatch or read error means the shadow WAL's continuation point can no longer be trusted.","triggerScenarios":"Thrown at db.go:1378 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure only one litestream process replicates a given database","If another writer reset the WAL, run 'litestream reset' and re-sync from a fresh snapshot","Inspect the wrapped error for the exact verification failure"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}