{"record":{"id":"aba4f1fdde8f07ad","repo":"benbjohnson/litestream","slug":"pos-w","errorCode":null,"errorMessage":"pos: %w","messagePattern":"pos: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"db.go","lineNumber":1344,"sourceCode":"\t\ts.lastSyncedWALOffset = exec.state.lastSyncedWALOffset\n\t})\n\n\t// Compute current index and total shadow WAL size.\n\tdb.txIDGauge.Set(float64(exec.pos.TXID))\n\n\t// Update file size metrics.\n\tif fi, err := os.Stat(db.path); err == nil {\n\t\tdb.dbSizeGauge.Set(float64(fi.Size()))\n\t}\n\tdb.walSizeGauge.Set(float64(exec.state.lastSyncedWALOffset))\n\n\treturn result, nil\n}\n\nfunc (db *DB) verifyAndSync(ctx context.Context, checkpointing bool, state *syncState) (syncResult, error) {\n\tpos, err := db.Pos()\n\tif err != nil {\n\t\treturn syncResult{}, fmt.Errorf(\"pos: %w\", err)\n\t}\n\n\treturn db.verifyAndSyncWithExecutor(ctx, checkpointing, &syncExecutor{\n\t\tstate: *state,\n\t\tpos:   pos,\n\t}, 0)\n}\n\nfunc (db *DB) verifyAndSyncWithExecutor(ctx context.Context, checkpointing bool, exec *syncExecutor, maxSyncWALBytes int64) (syncResult, error) {\n\tdb.setSyncDiagPhase(diagPhaseStatWAL, func(s *diagState) {\n\t\ts.txID = exec.pos.TXID + 1\n\t\ts.lastSyncedWALOffset = exec.state.lastSyncedWALOffset\n\t})\n\n\t// Use the last synced WAL offset as the logical size for checkpoint decisions.\n\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","sourceCodeStart":1326,"sourceCodeEnd":1362,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/db.go#L1326-L1362","documentation":"Wraps DB.Pos() failure at the start of DB.verifyAndSync during a sync. Fires when the database's current replication position (TXID/offset read via the SHM header) cannot be determined, aborting the verification-and-sync step.","triggerScenarios":"Thrown at db.go:1344 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions on the .litestream meta directory next to the database","Run 'litestream reset' to rebuild corrupted local LTX state"],"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-14T05:17:10.506Z"}