{"record":{"id":"7b4260041b18213f","repo":"benbjohnson/litestream","slug":"write-updated-page-d-w","errorCode":null,"errorMessage":"write updated page %d: %w","messagePattern":"write updated page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vfs.go","lineNumber":909,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"write page %d to hydrated file: %w\", pgno, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":891,"sourceCodeEnd":927,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L891-L927","documentation":"Hydrator.ApplyUpdates wraps a failure writing a fetched page into the local hydration file as \"write updated page %d\". The page was successfully fetched from replica storage but the local pwrite at offset (pgno-1)*pageSize failed.","triggerScenarios":"Disk full while writing the hydrated file; hydration file truncated or closed before ApplyUpdates; underlying storage I/O error; permission loss on the hydration file mid-run.","commonSituations":"Volume running out of space during heavy write workload; tmpfs hydration directory hitting size limits; disk removed or remounted read-only; file deleted by external cleanup jobs.","solutions":["Check disk free space on the hydration file's volume and expand if needed","Check the wrapped os.PathError for which path/operation failed","Confirm no external process is truncating or removing the hydration file","Use litestream reset to rebuild the hydration file if it is in a bad state"],"exampleFix":"// diagnose offset & size\noff := int64(pgno-1) * int64(h.pageSize)\nif _, err := h.file.WriteAt(data, off); err != nil {\n\treturn fmt.Errorf(\"write updated page %d at offset %d: %w\", pgno, off, err)\n}","handlingStrategy":"try-catch","validationCode":"// ensure room for the hydrated DB before updating\nif fi, err := os.Stat(hydrationPath); err == nil && fi.Size()+bytesNeeded > freeDisk(path) {\n\t// free space or enlarge volume first\n}","typeGuard":null,"tryCatchPattern":"if err := hydrator.ApplyUpdates(ctx, updates); err != nil {\n\tvar pe *os.PathError\n\tif errors.As(err, &pe) && errors.Is(pe.Err, syscall.ENOSPC) {\n\t\t// free space / resize volume, then litestream reset\n\t}\n}","preventionTips":["Size the hydration volume for the full database size plus headroom","Alert on disk usage thresholds (e.g. 80%)","Do not place hydration files on quota-limited tmpfs","Prevent external processes from truncating or deleting hydration files"],"tags":["io","filesystem","disk","vfs"],"backgroundTag":"file-write-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"}