{"record":{"id":"359a15997aefdf85","repo":"benbjohnson/litestream","slug":"fetch-page-d-w","errorCode":null,"errorMessage":"fetch page %d: %w","messagePattern":"fetch page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vfs.go","lineNumber":3063,"sourceCode":"\n\t\tif err := enc.EncodeHeader(ltx.Header{\n\t\t\tVersion:   ltx.Version,\n\t\t\tFlags:     ltx.HeaderFlagNoChecksum,\n\t\t\tPageSize:  pageSize,\n\t\t\tCommit:    commit,\n\t\t\tMinTXID:   1,\n\t\t\tMaxTXID:   pos.TXID,\n\t\t\tTimestamp: time.Now().UnixMilli(),\n\t\t}); err != nil {\n\t\t\tpw.CloseWithError(fmt.Errorf(\"encode header: %w\", err))\n\t\t\treturn\n\t\t}\n\n\t\tfor _, pgno := range pgnos {\n\t\t\telem := pages[pgno]\n\t\t\t_, data, err := FetchPage(ctx, f.client, elem.Level, elem.MinTXID, elem.MaxTXID, elem.Offset, elem.Size)\n\t\t\tif err != nil {\n\t\t\t\tpw.CloseWithError(fmt.Errorf(\"fetch page %d: %w\", pgno, err))\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err := enc.EncodePage(ltx.PageHeader{Pgno: pgno}, data); err != nil {\n\t\t\t\tpw.CloseWithError(fmt.Errorf(\"encode page %d: %w\", pgno, err))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif err := enc.Close(); err != nil {\n\t\t\tpw.CloseWithError(fmt.Errorf(\"close encoder: %w\", err))\n\t\t\treturn\n\t\t}\n\t\tpw.Close()\n\t}()\n\n\treturn f.client.WriteLTXFile(ctx, SnapshotLevel, 1, pos.TXID, pr)\n}\n","sourceCodeStart":3045,"sourceCodeEnd":3081,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L3045-L3081","documentation":"While building the snapshot, Snapshot reads each required page from remote LTX storage via FetchPage; this wraps any storage/decoding failure with the failing page number. It means one page's data could not be fetched from the replica storage, so the snapshot stream is aborted.","triggerScenarios":"FetchPage(ctx, f.client, elem.Level, elem.MinTXID, elem.MaxTXID, elem.Offset, elem.Size) returns an error during Snapshot — missing LTX file for the needed TXID range, network failure, or corrupted remote object.","commonSituations":"Remote replicas pruned/compacted away the LTX files covering the needed TXIDs; S3/network outage mid-snapshot; restored storage missing objects; stale local pos pointing at TXIDs no longer in remote.","solutions":["Re-sync the database so local LTX state matches what remote storage holds","Check remote storage for the LTX file covering the page's TXID range; restore missing objects from backup if pruned","Run litestream reset (or the documented reset path) to clear corrupted local LTX state and re-replicate","Retry after confirming network/connectivity to the replica storage"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"info, err := file.Snapshot(ctx)\nif err != nil && strings.Contains(err.Error(), \"fetch page\") {\n    // check remote LTX availability, then retry with backoff\n    time.Sleep(backoff)\n    info, err = file.Snapshot(ctx)\n}","preventionTips":["Monitor remote replica for missing/pruned LTX files before pruning aggressively","Ensure retention on remote covers the TXID ranges local state may reference","Handle transient network errors with bounded retries and backoff"],"tags":["go","storage","ltx","network"],"backgroundTag":"resource-not-found","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"}