Closed reidmix closed 9 years ago
Tagging: @dickeyxxx who worked on this fix with me, @pedro who determined the solution to this bug, and @amerine who reported this issue
In a situation using multiple processes or a setup like sidekiq that wouldn't share the mutex, you could see this come up. It would generally be very rare since it would be 2 different threads/processes running puts
at the same time.
I think we might be seeing it since we're running 2 schedulers (which is an issue by itself, I'll admit), but performing the log atomically vs a mutex I think is a better solution to the problem anyways.
:+1:
:+1:
We have also been seeing this for months (see #64)
:+1:
Not sure why I never received any of these emails.
Regardless this seems pretty straight forward.
Mind updating @reidmix and I when when this is released?
Looks like this broke using syslog
, since the syslog class only has a puts
method: https://github.com/asenchi/scrolls/blob/master/lib/scrolls/syslog.rb#L38.
Hello @dbussink Good call out. Looking at your PR as well. I'm picking things back up and hope to get the project cleaned up over the next week. Sorry for the lack of maintenance here.
When using multiple threads we are running into a scenario using SideKiq/SideTiq where the mutex in
Scrolls::Log#write
isn't doing what we expect. Even with the mutex, it is not shared across threads, and in the following example, the two loglines are not being separated out with a newline as we'd expect:To simplify the case, we can see that
puts
is not atomic:A solution is to use
print
, it is atomic and works as expected (even without the mutex):Additionally, removing the
rescue
that was an artifact from an old refactor: https://github.com/asenchi/scrolls/commit/60e7220341cd02de006991d35934b1bd7f6f3cd2