Files
seaweedFS/weed/server
Chris Lu fdb888729b fix: properly handle errors in writeToFile to prevent 0-byte EC shards (#7620)
Fixes #7619

The writeToFile function had two critical bugs that could cause data loss
during EC shard evacuation when the destination disk is full:

Bug 1: When os.OpenFile fails (e.g., disk full), the error was silently
ignored and nil was returned. This caused the caller to think the copy
succeeded.

Bug 2: When dst.Write fails (e.g., 'no space left on device'), the error
was completely ignored because the return value was not checked.

When evacuating EC shards to a full volume server (especially on BTRFS):
1. OpenFile may succeed (creates 0-byte file inode)
2. Write fails with 'no space left on device'
3. Errors were ignored, function returned nil
4. Caller thinks copy succeeded and deletes source shard
5. Result: 0-byte shard on destination, data loss!

This fix ensures both errors are properly returned, preventing data loss.
Added unit tests to verify the fix.
2025-12-04 14:52:03 -08:00
..
2019-03-03 10:17:44 -08:00
2024-08-01 13:00:54 -07:00
2025-09-18 14:46:53 -07:00