in reply to NFS File Locking

That code looks like some kind of import program where various clients put some information in a file share and it gets slurped and processed.

My immediate solution would be to identify the unique key information from the files to be processed and put them in a process log of some kind (or preferably a DB) and then run a quick check to see if the data has already been entered before proceeding with the import.

When you find an error (file already processed) you can store that in a junk folder for later evaluation and troubleshooting.

I would create a test server and a bunch of bot type clients that try to import data by the thousands to see if and when you can recreate the problem. I would exclusively unlock the file to see if that changes things (code snippet from the POD for flock):

flock($fh, LOCK_UN) or die "Cannot unlock mailbox - $!\n";

Celebrate Intellectual Diversity