|Keep It Simple, Stupid|
Re^2: Strange IO + concurrency issueby vsespb (Hermit)
|on Sep 28, 2013 at 17:11 UTC||Need Help??|
1. You are opening a lock to a semaphore file (lock.tmp).I knew that if lock extended to other steps it works, but I could not understand why.
The thing is: When I open file on step (2), I write to it in step (4). But steps (4) and (5) are actually protected. Steps (4) and (5) is performed only if that process was the one who created file. Otherwise step is skipped. (and this was intentional - I was trying to minimize lock time which was important)
Notice "if ($f)"
Problem was that step (6) unprotected. And this assertion was wrong:
die if -s $filename != -s $newfilename;Correct assertion would be:
die if 40_000_000 != -s $newfilename;i.e. when data copied, file could be in the middle of creation by another process. so in the end I see:
correct size of $filename
wrong size of $newfilename
assertion passed: if -s $filename != -s $newfilename;
Thank you! I'll mark post as SOLVED