I have a basic script that I want to do the following :
Now - if 2 servers were to run this same script at the same exact time (having access to the same NFS file share) :
From what I can find online, it looks like an error would just get thrown by Server 2 - but no file corruption or anything should be of concern : http://nfs.sourceforge.net/
The file handle refers to a deleted file. After a file is deleted on the server, clients don't find out until they try to access the file with a file handle they had cached from a previous LOOKUP. Using rsync or mv to replace a file while it is in use on another client is a common scenario that results in an ESTALE error.
I've tried simulating this to confirm but haven't been able to do so successfully - so I wanted to check here before implementing this strategy :
Question : Is my understanding accurate - or do I need to use a different strategy to ensure the file.txt doesn't get corrupted?
Additional details : Amazon Linux OS. The drive is mounted is nsf4 . The file could be as large as 100MB
The check-if-file-exists is a typical TOCTTOU problem.
The simplest fix is to just not check, and try to mv
. If there is no file to be moved, the mv
will fail (and not do anything).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.