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.

CommentFileSizeAuthor
jsonlog-flock.patch582 bytesklavs

Comments

jacobfriis’s picture

Assigned: Unassigned » jacobfriis
Category: Bug report » Feature request

@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'?

klavs’s picture

it'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).

jacobfriis’s picture

OK, I get it ;-) File locking doesn't worsen the situation, because no matter what - there's always only _one_ process that can write.

  • jacobfriis committed b01a272 on 7.x-1.x
    * Use file locking (issue #2373039).
    
  • jacobfriis committed de34370 on 7.x-1.x
    * Use file locking (issue #2373039).
    * Renamed 'event_id' to 'message_id...
jacobfriis’s picture

Status: Active » Fixed

Implemented in release 7.x-1.2.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.