{"record":{"id":"28248d89d27a3478","repo":"benbjohnson/litestream","slug":"fetch-updated-page-d-w","errorCode":null,"errorMessage":"fetch updated page %d: %w","messagePattern":"fetch updated page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vfs.go","lineNumber":904,"sourceCode":"\n\t// Update the first page to pretend like we are in journal mode\n\tif off == 0 && len(p) >= 28 {\n\t\tp[18], p[19] = 0x01, 0x01\n\t\t_, _ = rand.Read(p[24:28])\n\t}\n\n\treturn n, nil\n}\n\n// ApplyUpdates fetches updated pages and writes them to the hydration file.\nfunc (h *Hydrator) ApplyUpdates(ctx context.Context, updates map[uint32]ltx.PageIndexElem) error {\n\th.mu.Lock()\n\tdefer h.mu.Unlock()\n\n\tfor pgno, elem := range updates {\n\t\t_, data, err := FetchPage(ctx, h.client, elem.Level, elem.MinTXID, elem.MaxTXID, elem.Offset, elem.Size)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"fetch updated page %d: %w\", pgno, err)\n\t\t}\n\n\t\toff := int64(pgno-1) * int64(h.pageSize)\n\t\tif _, err := h.file.WriteAt(data, off); err != nil {\n\t\t\treturn fmt.Errorf(\"write updated page %d: %w\", pgno, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// WritePage writes a single page to the hydration file.\nfunc (h *Hydrator) WritePage(pgno uint32, data []byte) error {\n\th.mu.Lock()\n\tdefer h.mu.Unlock()\n\n\toff := int64(pgno-1) * int64(h.pageSize)\n\tif _, err := h.file.WriteAt(data, off); err != nil {","sourceCodeStart":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L886-L922","documentation":"Hydrator.ApplyUpdates fetches a changed page from the replica storage via FetchPage and wraps any failure as \"fetch updated page %d\". During incremental hydration, the page index reports which pages changed; each must be downloaded from the replica client. A storage/network failure fetching any page aborts the whole update application.","triggerScenarios":"Calling ApplyUpdates when the replica storage is unreachable (network outage, wrong bucket/endpoint credentials); the referenced LTX file at elem.Level/elem.MinTXID/elem.MaxTXID was deleted by retention before the fetch; context canceled mid-fetch.","commonSituations":"S3/GCS/Azure credentials rotated or expired; retention policy removed LTX files the local page index still references; transient network partition during long-running replication; misconfigured endpoint in replica config.","solutions":["Read the wrapped cause: network/DNS errors indicate connectivity; 404/NoSuchKey indicates the LTX file was removed by retention — lengthen retention or disable it if a lifecycle policy is in place","Verify replica credentials and endpoint configuration","Retry the operation — ApplyUpdates can be re-run and will re-fetch the failed page","Use litestream reset for the database to rebuild hydration state from scratch if the page index is stale"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify replica reachability before long operations\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\ndefer cancel()\nif _, err := client.Head(ctx, replicaURL); err != nil {\n\t// storage unreachable — fix credentials/endpoint first\n}","typeGuard":null,"tryCatchPattern":"err := hydrator.ApplyUpdates(ctx, updates)\nif err != nil {\n\tif errors.Is(err, context.DeadlineExceeded) || isRetryableStorageErr(err) {\n\t\t// backoff and retry; ApplyUpdates is idempotent\n\t}\n}","preventionTips":["Set retention long enough that LTX files outlive any hydration catch-up window","Rotate storage credentials before expiry and validate with a smoke test","Configure network retries/backoff in the replica client and monitor connectivity","Pin replica endpoint/bucket config and validate it with litestream replicas"],"tags":["network","storage","replication","ltx"],"backgroundTag":"network-request-failed","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"}