{"record":{"id":"65c63f5f5661a382","repo":"benbjohnson/litestream","slug":"write-page-to-buffer-w","errorCode":null,"errorMessage":"write page to buffer: %w","messagePattern":"write page to buffer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vfs.go","lineNumber":2224,"sourceCode":"\n// writeToBuffer writes a dirty page to the write buffer for durability.\n// If the page already exists in the buffer, it overwrites at the same offset.\n// Otherwise, it appends to the end of the file.\n// Must be called with f.mu held.\nfunc (f *VFSFile) writeToBuffer(pgno uint32, data []byte) error {\n\tvar writeOffset int64\n\tif existingOff, ok := f.dirty[pgno]; ok {\n\t\t// Page already exists - overwrite at same offset\n\t\twriteOffset = existingOff\n\t} else {\n\t\t// New page - append to end of file\n\t\twriteOffset = f.bufferNextOff\n\t\tf.bufferNextOff += int64(len(data))\n\t}\n\n\t// Write page data (no header, just raw page data)\n\tif _, err := f.bufferFile.WriteAt(data, writeOffset); err != nil {\n\t\treturn fmt.Errorf(\"write page to buffer: %w\", err)\n\t}\n\n\t// Update dirty map with offset\n\tf.dirty[pgno] = writeOffset\n\n\treturn nil\n}\n\n// clearWriteBuffer clears and resets the write buffer after successful sync.\nfunc (f *VFSFile) clearWriteBuffer() error {\n\t// Truncate file to zero\n\tif err := f.bufferFile.Truncate(0); err != nil {\n\t\treturn fmt.Errorf(\"truncate buffer: %w\", err)\n\t}\n\n\t// Reset next write offset\n\tf.bufferNextOff = 0\n","sourceCodeStart":2206,"sourceCodeEnd":2242,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L2206-L2242","documentation":"VFSFile.writeToBuffer's WriteAt of a dirty page into the durability buffer file failed. The buffer file (buffer_path) is unwritable or the disk is full — dirty pages can no longer be staged safely before replication.","triggerScenarios":"Thrown at vfs.go:2224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and permissions on the buffer file path","Verify buffer_path points to writable storage"],"exampleFix":null,"handlingStrategy":"retry","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"}