I noticed that you were not using LOCK_EX on file_put_contents, which could result in issues with simultaneous writing to the file.. might as well just use locking :)
Attached patch.
| Comment | File | Size | Author |
|---|---|---|---|
| jsonlog-flock.patch | 582 bytes | klavs |
I noticed that you were not using LOCK_EX on file_put_contents, which could result in issues with simultaneous writing to the file.. might as well just use locking :)
Attached patch.
| Comment | File | Size | Author |
|---|---|---|---|
| jsonlog-flock.patch | 582 bytes | klavs |
Comments
Comment #1
jacobfriis commented@klavs
What happens if the truncation setting is more than 4(Kb ~ more than block size) and a lot of processes want to log long messages, and the write attempts 'pile up'?
Comment #2
klavs commentedit'll wait until the first write is done. luckily you're using a filesystem - so as long as that performs well - writes will get through.
I haven't looked at the C code for file_put_contents - so I think you'll have to wait the same - even if you do no locking - as it'll hang and wait for IO completion.. (just not in an ordered fashion, due to no locking).
Comment #3
jacobfriis commentedOK, I get it ;-) File locking doesn't worsen the situation, because no matter what - there's always only _one_ process that can write.
Comment #5
jacobfriis commentedImplemented in release 7.x-1.2.