[Backgroundrb-devel] Bug in Rails worker creation through scheduler

Mathias Meyer mm at beatsteaks.de
Tue Apr 24 10:44:15 EDT 2007

Hi Folks!

A small bug in the Scheduler code caused a small nightmare for me  
over the last hours. The symptoms were that my scheduled worker  
(Rails-based) wouldn't start. Nothing in the log files, no errors on  
the console, no hints whatsoever about what went wrong. So I filled  
up the code with logging statements and tracked down the problem to  
line 48 of server/lib/backgroundrb/scheduler.rb.
The following statement in that line is bogus:
48:  BackgrounDRb::ServerLogger.log_exception('scheduler', e)
Since there's no e defined in the rescue statement, the above  
statement fails badly and therefore nothing gets logged anywhere.

The fix is to either use this style:
48:  BackgrounDRb::ServerLogger.log_exception('scheduler', $!)
or this one:
47:rescue Exception => e
48:  BackgrounDRb::ServerLogger.log_exception('scheduler', e)

This issue seems to hit when something went wrong in the  
initialization of the worker, in my case, an error in the Rails  
environment setup. So if you're finding yourself wondering why your  
workers aren't doing anything, you should check that there's no  
exception being swallowed.

Cheers, Mathias
// Mathias Meyer
// www.paperplanes.de

More information about the Backgroundrb-devel mailing list