New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content corruption when file is open during overwrite on bucket #2413
Comments
Could you share more about the expected behavior? Without file locking, I expect uncoordinated writers to create arbitrary changes to the file which might appear to be corruption. s3fs That said, s3fs could reduce but not eliminate the appearance of corruption by using |
I've probably done a poor job at my explanation. In the sequence above, the step "Overwrite the object |
When you open an object mounted with s3fs using At first, s3fs downloads the contents of the file and save it to a file, and the contents of that file are then read by the vi process. When s3fs started with However, if the Note that if the file is small and does not depend on this |
I raised the issue because the behavior differs if you push new content to the bucket while the file is open in vi or not, hence I think there is indeed an issue somewhere. |
@hbs Thanks for your quickly reply.
I'm interested in these results. (By the way, I haven't had the same problem regardless of these option.) |
One current example of the issue has the following elements:
File size is indeed 26689926 bytes, the sparse file in the cache contains only |
The issue encountered might be to caching at the fuse level. How would s3fs behave in terms of access to the cache if the |
Another weirdness when the corruption happen, the stat file (under How can it be that the stat file thinks the file was modified when the fs is read only? |
With the This seems somehow similar to #715 |
@hbs I've been asked several questions, so I'll provide a series of answers below: First, if you specify the Next is the cache file information file under Also, the file content cache created under Then, when a file is opened and read, a portion (or all) of the file content is downloaded from the S3 server and stored in a cache file. The cache file is used in this way, so even if it is mounted in RO mode, it is a file that is updated when it is downloaded. If possible, please provide detailed steps to reproduce your problem or identify the cause. |
Hi, thanks for your comment. I'll try to detail further what is occurring so you can maybe identify the code to look for. The set up is a bucket mounted in RO mode on a server. The bucket contains tens of thousands of files. The application accessing those files may keep them open for a very long period of time. The issue which arises is that sometimes the application is provided with content which includes ranges in HOLE state. This is confirmed by simply looking at the problematic file via The application may be closed from time to time, either cleanly, i.e. with files being closed before shutdown, or violently with no explicit file closing. The s3fs cache is not cleaned upon startup as it contains several terabytes of data which would take quite some time to redownload with a significant impact on the application's performance while it is populated. So in our setup, no files are ever modified (files could be modified on the bucket side when I initially filed the issue but this possibility has now been removed but we still experience the issue). If I understand correctly what you wrote regarding the range files under Regarding the logs, given the amount of file access performed by the production application where the issue arises, I don't think I will be able to provide them, unless there is a way to rotate those logs once they reach a certain size so we can limit the total amount of space used by them. |
@hbs Thank you for the detailed explanation. The cache file and its stat file are implemented based on the following assumptions: There is a HOLE in the cache file created by s3fs, but when reading(accessing) the range of the HOLE area, that area is newly downloaded from the S3 server, written it to the HOLE area, and the HOLE is filled. Even if a file is read from multiple processes, the read is performed via this cache file, and the same cache is shared and updated. When reading an uncached range (HOLE), the read range is downloaded from the S3 server, written to the cache file, and the HOLE is filled. When s3fs is terminated(not forced), any open files are closed. After (re)starting s3fs, these cache files and cache stat files will be loaded and used again when you open the file. When opening a file, the stat of the file on the S3 server is compared with the cache file's one(mtime and file size) to determine whether the cache file is stale. The s3fs cache is designed and implemented like this. Unfortunately, I have not yet been able to reproduce the same phenomenon as this issue, so I am not able to understand the cause. |
Seems like I experience the same issue. S3 bucket mounted via fstab in readonly mode. Files in s3 is not modified. fstab config
System and s3fs versionsDebian 12.5Linux jupyter2 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux Corrupted file is filled with zeros, content of .stat file
|
Additional Information
Version of s3fs being used (
s3fs --version
)V1.93
Version of fuse being used (
pkg-config --modversion fuse
,rpm -qi fuse
ordpkg -s fuse
)2.9.9-3
Kernel information (
uname -r
)Linux sl911168 5.4.0-171-generic #189-Ubuntu SMP Fri Jan 5 14:23:02 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
GNU/Linux Distribution, if applicable (
cat /etc/os-release
)Ubuntu
How to run s3fs, if applicable
s3fs syslog messages (
grep s3fs /var/log/syslog
,journalctl | grep s3fs
, ors3fs outputs
)Details about issue
The following sequence allowed us to reproduce the issue most of the time:
FOO
on the bucketFOO
usingvi
on the machine where the bucket is mountedFOO
on the bucket with new contentcat FOO
on the machine where the bucket is mountedvi
cat FOO
againMost of the time the content of object
FOO
is not updated.Doing the same without launching
vi
, i.e. without having the file open at the time its content is overwritten, leads to correct result with the lattercat FOO
returning the new content.The text was updated successfully, but these errors were encountered: