[GH-ISSUE #85] write error (race condition?) #25

Closed
opened 2026-03-04 02:11:28 +03:00 by kerem · 9 comments
Owner

Originally created by @pkeane on GitHub (May 17, 2012).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/85

I've been getting this message regularly when hitting the app w/ batch processes (nb., /path/to/log/file.log IS valid & writeable and was successfully written to by the 800 or so operations previous to this):

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/path/to/log/file.log" could not be opened; it may be invalid or not writable.' in /var/www/daseframework/lib/Monolog/Handler/StreamHandler.php:67
Stack trace:
#0 /var/www/daseframework/lib/Monolog/Handler/AbstractProcessingHandler.php(41): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/daseframework/lib/Monolog/Logger.php(191): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/daseframework/lib/Monolog/Logger.php(294): Monolog\Logger->addRecord(100, 'INSERT INTO ite...', Array)
#3 /var/www/daseframework/lib/Dase/DBO.php(190): Monolog\Logger->debug('INSERT INTO ite...')
#4 /var/www/daseframework/lib/Dase/DBO/Item.php(162): Dase_DBO->insert()

perhaps there is a race condition??

Originally created by @pkeane on GitHub (May 17, 2012). Original GitHub issue: https://github.com/Seldaek/monolog/issues/85 I've been getting this message regularly when hitting the app w/ batch processes (nb., /path/to/log/file.log IS valid & writeable and was successfully written to by the 800 or so operations previous to this): Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/path/to/log/file.log" could not be opened; it may be invalid or not writable.' in /var/www/daseframework/lib/Monolog/Handler/StreamHandler.php:67 Stack trace: #0 /var/www/daseframework/lib/Monolog/Handler/AbstractProcessingHandler.php(41): Monolog\Handler\StreamHandler->write(Array) #1 /var/www/daseframework/lib/Monolog/Logger.php(191): Monolog\Handler\AbstractProcessingHandler->handle(Array) #2 /var/www/daseframework/lib/Monolog/Logger.php(294): Monolog\Logger->addRecord(100, 'INSERT INTO ite...', Array) #3 /var/www/daseframework/lib/Dase/DBO.php(190): Monolog\Logger->debug('INSERT INTO ite...') #4 /var/www/daseframework/lib/Dase/DBO/Item.php(162): Dase_DBO->insert() perhaps there is a race condition??
kerem closed this issue 2026-03-04 02:11:28 +03:00
Author
Owner

@katanacrimson commented on GitHub (May 17, 2012):

It's probably file locking - I take it you're encountering this on linux?

<!-- gh-comment-id:5771588 --> @katanacrimson commented on GitHub (May 17, 2012): It's probably file locking - I take it you're encountering this on linux?
Author
Owner

@pkeane commented on GitHub (May 17, 2012):

YES - linux (RedHat):

uname -a
Linux [...].utexas.edu 2.6.32-220.7.1.el6.x86_64 #1 SMP Fri Feb 10 15:22:22 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

<!-- gh-comment-id:5771805 --> @pkeane commented on GitHub (May 17, 2012): YES - linux (RedHat): uname -a Linux [...].utexas.edu 2.6.32-220.7.1.el6.x86_64 #1 SMP Fri Feb 10 15:22:22 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
Author
Owner

@katanacrimson commented on GitHub (May 17, 2012):

Perhaps you should the syslog handler or hack together a handler that blind-fires to a remote logger on another system (which would be hooked up to a full DBMS) up instead - that would allow simultaneous logging.

My bet is that you're probably just hitting file locking, which isn't something that can be helped, really.

ed: SocketHandler or SyslogHandler are the best options for you IMO

<!-- gh-comment-id:5772061 --> @katanacrimson commented on GitHub (May 17, 2012): Perhaps you should the syslog handler or hack together a handler that blind-fires to a remote logger on another system (which would be hooked up to a full DBMS) up instead - that would allow simultaneous logging. My bet is that you're probably just hitting file locking, which isn't something that can be helped, really. ed: SocketHandler or SyslogHandler are the best options for you IMO
Author
Owner

@pkeane commented on GitHub (May 17, 2012):

Great. Thanks!

<!-- gh-comment-id:5772207 --> @pkeane commented on GitHub (May 17, 2012): Great. Thanks!
Author
Owner

@Seldaek commented on GitHub (May 21, 2012):

That's quite weird, I'd think opening a stream multiple times in "append" mode would be no problem. @damianb do you know if that's a platform specific issue?

<!-- gh-comment-id:5819910 --> @Seldaek commented on GitHub (May 21, 2012): That's quite weird, I'd think opening a stream multiple times in "append" mode would be no problem. @damianb do you know if that's a platform specific issue?
Author
Owner

@katanacrimson commented on GitHub (May 22, 2012):

if it was, it'd be observed much more often; it's just a linux system.

could be filesystem related, but my bet is that he's not on anything exotic; probably ext2/3/4.

<!-- gh-comment-id:5838082 --> @katanacrimson commented on GitHub (May 22, 2012): if it was, it'd be observed much more often; it's just a linux system. could be filesystem related, but my bet is that he's not on anything exotic; probably ext2/3/4.
Author
Owner

@Seldaek commented on GitHub (Aug 18, 2012):

I fixed the code now so that it doesn't hide the php error but exposes it to the user, so if you update to latest you should see different errors, and hopefully it gives us a better insight as to what is happening.

<!-- gh-comment-id:7845806 --> @Seldaek commented on GitHub (Aug 18, 2012): I fixed the code now so that it doesn't hide the php error but exposes it to the user, so if you update to latest you should see different errors, and hopefully it gives us a better insight as to what is happening.
Author
Owner

@Seldaek commented on GitHub (Nov 11, 2012):

No news here?

<!-- gh-comment-id:10269352 --> @Seldaek commented on GitHub (Nov 11, 2012): No news here?
Author
Owner

@Seldaek commented on GitHub (Jan 7, 2013):

I'll close since there is no feedback, but if it crops up again with the latest version let me know.

<!-- gh-comment-id:11969225 --> @Seldaek commented on GitHub (Jan 7, 2013): I'll close since there is no feedback, but if it crops up again with the latest version let me know.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#25
No description provided.