[GH-ISSUE #2581] [Data Corruption]File is truncated with padding-zeros after backend server restarted #1240

Open
opened 2026-03-04 01:52:30 +03:00 by kerem · 0 comments
Owner

Originally created by @hbao0915 on GitHub (Oct 30, 2024).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/2581

Additional Information

Version of s3fs being used (s3fs --version)

v1.87, v1.91, v1.95

Details about issue

The issue description in short: s3fs is opening and reading file while S3 server is restarted, file could be truncated with padding zeroes, which causes data corruption.

I tracked the code, and found that the bug is in this stack: s3fs_open -> check_object_access -> get_object_attribute

Inside get_object_attribute, if an HEAD with 503 response (or other 5xx resp, or timeout err) would be returned because of backend being down for a while, then s3fs tries to send HEAD with filename plus "_$folder$". If the backend server recovers now, a 404 resp will be returned. Then s3fs consider the file not existing, and s3fs would call FdManager::Open with st.size=0, which will result in file being truncated.

Originally created by @hbao0915 on GitHub (Oct 30, 2024). Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/2581 ### Additional Information #### Version of s3fs being used (`s3fs --version`) v1.87, v1.91, v1.95 ### Details about issue <!-- Please describe the content of the issue in detail. --> The issue description in short: s3fs is opening and reading file while S3 server is restarted, file could be truncated with padding zeroes, which causes **data corruption**. I tracked the code, and found that the bug is in this stack: s3fs_open -> check_object_access -> get_object_attribute Inside `get_object_attribute`, if an HEAD with 503 response (or other 5xx resp, or timeout err) would be returned because of backend being down for a while, then s3fs tries to send HEAD with filename plus "_$folder$". If the backend server recovers now, a 404 resp will be returned. Then s3fs consider the file not existing, and s3fs would call FdManager::Open with st.size=0, which will result in file being truncated.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/s3fs-fuse#1240
No description provided.