note 124969 added to function.flock
| From: | guy at inveniem dot com | Date: | Fri, 01 May 2020 00:34:46 +0000 |
| Subject: | note 124969 added to function.flock | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214565@lists.php.net to get a copy of this message | ||
We found that using
flock() in conjunction with fputcsv() to allow
concurrent processes to write 1,000+ rows results in 5% of the rows being lost for some reason. It
did not matter whether we opened the file in append mode (a), or opened it in read-write (r+) mode
and then seeked AFTER the flock() call -- either way, rows were lost.
For this reason, we ended up having to use a separate lock file.
Failing code, failing results, and passing code can be found here:
https://gist.github.com/GuyPaddock/371d42970e94d0e3f1087db6d91bfe02
----
Server IP: 45.112.84.4
Probable Submitter: 38.142.137.34 (proxied: 52.250.119.245)
----
Manual Page -- http://php.net/manual/en/function.flock.php
Edit -- https://master.php.net/note/edit/124969
Del: integrated -- https://master.php.net/note/delete/124969/integrated
Del: useless -- https://master.php.net/note/delete/124969/useless
Del: bad code -- https://master.php.net/note/delete/124969/bad+code
Del: spam -- https://master.php.net/note/delete/124969/spam
Del: non-english -- https://master.php.net/note/delete/124969/non-english
Del: in docs -- https://master.php.net/note/delete/124969/in+docs
Del: other reasons-- https://master.php.net/note/delete/124969
Reject -- https://master.php.net/note/reject/124969
Search -- https://master.php.net/manage/user-notes.php