mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
Dirty pages that weed mount buffers in the swap file (non-sequential writes, or when the memory chunks run out) also serve reads until they upload. SwapFileChunk.ReadDataAt logged a read error and stopped, returning only how far it had read; UploadPipeline.MaybeReadDataAt and DirtyPages.ReadDirtyDataAt passed that offset up. The mount read path then served the rest of the range from the stored chunks or from zeros, and the read returned OK. A read error on the cache disk, or a swap file truncated by an outside cleanup, is enough: the application reads back bytes it was told were written and gets other bytes, with no error anywhere. This is the read-side twin of #13198, which made the upload of those bytes fail. PageChunk.ReadDataAt, UploadPipeline.MaybeReadDataAt and DirtyPages.ReadDirtyDataAt now return an error besides the offset. A swap chunk that cannot read back an interval overlapping the requested range returns it, wrapping the new ErrDirtyDataUnreadable and the read error (a short read is io.ErrUnexpectedEOF). Intervals outside the range are not read, so a read that does not touch the lost bytes still succeeds. MemChunk cannot fail. The read handler and copy_file_range turn the error into EIO. Read does not refresh the filer entry and retry for this error, since the entry has no say over bytes that only exist in the swap file. A failed read does not mark the handle failed. Reads of other ranges and writes keep working, and the upload path already records the failure when it cannot read the same bytes, so flush, fsync and close return EIO. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>