From: noreply@... Date: 2006-10-05T18:08:34+09:00 Subject: [ ruby-Patches-6031 ] Bug in logger.rb rotation in multi-process environment Patches item #6031, was opened at 2006-10-05 09:08 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1700&aid=6031&group_id=426 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Guy Rosen (guyrosen) Assigned to: Nobody (None) Summary: Bug in logger.rb rotation in multi-process environment Initial Comment: Hi, There is a bug in logger.rb's rotation that causes it to either misbehave or fail the application when running in a multi-process environment - specifically Rails. I have Ruby on Rails under FastCGI, with multiple dispatch.fcgi processes running. My logger is configured for daily rotation. The problematic scenario is this: - Come midnight, the _first_ Rails process that happens to get a request renames the log file (production.log => production.log.yyyymmdd) - Subsequently, the remaining Rails processes attempt to rename the file as well, but fail completely because production.log.yyyymmdd already exists. Logger raises an exception, and users receive "500 Internal Server Error". - Until all Rails processes are restarted, only the first one will work and all the rest will continue to fail violently. I'm attaching a patch for logger.rb that fixes shift_log_period so that it doesn't fail violently if log.yyyymmdd already exists, but rather just reopens the logfile and keeps on working. Note there is probably also a bug when rotating by size (shift_log_age) in the same environment (haven't tested or fixed it, but reading the code seems to indicate it will happen). Although nothing will fail violently, each Rails process, ignorant of its peers, will rotate the logs and the end result will be multiple rotations! - Guy. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1700&aid=6031&group_id=426