[Backgroundrb-devel] Feedback on RC2

Andy Tyra andy.tyra at gmail.com
Thu Dec 6 20:31:58 EST 2007


Another issue to report.

When running the aforementioned worker manually, it runs and seems to work,
but the worker process crashes at the end, leaving this stack trace:

rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/nbio.rb:55:in
`dump': can't dump anonymous class #<Class:0xb6a4ccc8> (TypeError)
        from
rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/nbio.rb:55:in
`dump_object'
        from
rails-root/vendor/plugins/backgroundrb/framework/worker.rb:32:in `send_data'
        from
rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:79:in
`send_response'
        from rails-root/lib/workers/expire_and_refresh_worker.rb:36:in
`process_request'
        from
rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:48:in
`receive_data'
        from
rails-root/vendor/plugins/backgroundrb/framework/worker.rb:54:in
`receive_internal_data'
        from
rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:30:in
`extract'
        from
rails-root/vendor/plugins/backgroundrb/framework/worker.rb:52:in
`receive_internal_data'
         ... 11 levels...
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:19:in
`run'
        from
rails-root/vendor/plugins/backgroundrb/server/master_worker.rb:114:in
`initialize'
        from script/backgroundrb:73:in `new'
        from script/backgroundrb:73

It looked like this was because my worker method was not returning anything,
so I added the line

return "I am done."

to the end of the worker method.

I am now getting this stack trace:


rails-root/vendor/plugins/backgroundrb/framework/meta_pimp.rb:55:in
`process_response': You have a nil object when you didn't expect it!
(NoMethodError)
The error occurred while evaluating nil.instance        from
rails-root/vendor/plugins/backgroundrb/framework/meta_pimp.rb:28:in
`handle_object'
        from
rails-root/vendor/plugins/backgroundrb/framework/meta_pimp.rb:19:in
`receive_data'
        from
rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:30:in
`extract'
        from
rails-root/vendor/plugins/backgroundrb/framework/meta_pimp.rb:17:in
`receive_data'
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:81:in
`handle_internal_messages'
        from rails-root/vendor/plugins/backgroundrb/framework/core.rb:138:in
`start_reactor'
        from rails-root/vendor/plugins/backgroundrb/framework/core.rb:136:in
`each'
        from rails-root/vendor/plugins/backgroundrb/framework/core.rb:136:in
`start_reactor'
        from rails-root/vendor/plugins/backgroundrb/framework/core.rb:128:in
`loop'
        from rails-root/vendor/plugins/backgroundrb/framework/core.rb:128:in
`start_reactor'
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:20:in
`run'
        from
rails-root/vendor/plugins/backgroundrb/server/master_worker.rb:114:in
`initialize'
        from script/backgroundrb:73:in `new'
        from script/backgroundrb:73


On Dec 6, 2007 4:31 PM, Andy Tyra <andy.tyra at gmail.com> wrote:

> Hi There,
>
> Thanks for the help!  I have made some progress.
>
> It looks like the worker is crashing because it is not getting passed the
> argument that it requires to run.  That would explain why kicking this
> worker off manually worked just fine, but doing so in the scheduler did
> not.  The problem is, I need to be able to pass a parameter to this worker's
> function using the scheduling YML and that doesn't seem to be working.
> Perhaps you can help troubleshoot?
>
> Here is the relevant method from the worker which is named
> ExpireAndRefreshWorker:
>
>   def execute_report(report_name)
>         myReport = Report.new(report_name)
>         begin
>                 File.delete (File.join(RAILS_ROOT, 'public','reports',
> myReport.const_name + '.html'))
>         rescue
>                 #do nothing
>         end
>         renderController = FakeTest.new
>         renderController.render_report (myReport)
>   end
>
> As you can see, it takes one parameter, report_name, which should be a
> string.
>
> Here's the YML I'm trying to use to schedule it:
>
> :schedules:
>   :expire_and_refresh_worker:
>     :worker_method: execute_report
>     :data: unfilled_demand
>     :trigger_args: 0 */15 * * * * *
>     :job_key: unfilled_demand_schedule
>
> And here's the stack trace of the exception that is thrown when the
> schedule triggers:  (Please note that the line numbers in my stack trace
> will not match yours for script/backgroundrb.  I've added some additional
> tasks to this script that add YML scheduling
>
> rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:91:in
> `execute_report': wrong number of arguments (0 for 1) (ArgumentError)
>         from
> rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:91:in `send'
>         from
> rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:91:in
> `check_for_timer_events'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:129:in
> `start_reactor'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:128:in `loop'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:128:in
> `start_reactor'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/worker.rb:21:in
> `start_worker'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:152:in
> `fork_and_load'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:111:in
> `load_workers'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:106:in
> `each'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:106:in
> `load_workers'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:19:in
> `run'
>         from
> rails-root/vendor/plugins/backgroundrb/server/master_worker.rb:114:in
> `initialize'
>         from script/backgroundrb:73:in `new'
>         from script/backgroundrb:73
>
> It appears the parameter specified as :data in the yml is not getting
> passed to the function.  Is there some other way this should be done?  I
> don't see it in the doco.  Is it done as :args like in the old version?
>
> Also, this is unrelated, but I just thought I'd point it out.  The
> following stack trace appears in the logs when stopping backgroundrb:
>
> rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/nbio.rb:20:in
> `read_data': Packet::DisconnectError (Packet::DisconnectError)
>         from
> rails-root/vendor/plugins/backgroundrb/framework/worker.rb:47:in
> `handle_internal_messages'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:138:in
> `start_reactor'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:136:in `each'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:136:in
> `start_reactor'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:128:in `loop'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/core.rb:128:in
> `start_reactor'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/worker.rb:21:in
> `start_worker'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:152:in
> `fork_and_load'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:128:in
> `start_worker'
>         from
> rails-root/vendor/plugins/backgroundrb/server/master_worker.rb:115:in
> `initialize'
>         from
> rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:18:in
> `run'
>         from
> rails-root/vendor/plugins/backgroundrb/server/master_worker.rb:114:in
> `initialize'
>         from script/backgroundrb:73:in `new'
>         from script/backgroundrb:73
>
> And, a question.  I think I've figured out where everything is getting
> logged.  Will this version eventually log things like the old version?  The
> old version would report when workers stopped and started, when schedules
> were loaded and triggered, etc.  Is there somewhere you'd like this sort of
> thing submitted as a feature request?
>
> Thanks,
> Andy
>
>
> On Dec 5, 2007 6:54 PM, hemant kumar <gethemant at gmail.com> wrote:
>
> >
> > On Wed, 2007-12-05 at 17:51 -0800, Andy Tyra wrote:
> > > I tried to upgrade my existing application to RC2 last night.  Like
> > > many, I use this mostly for running scheduled tasks.  For the moment,
> > > I've abandoned the effort, but am looking forward to being able to use
> > > this.  Feedback below:
> > >
> > > First, the reason I was looking forward to this upgrade was to use the
> > > threaded scheduler.  I have an application with long-running tasks.  I
> >
> > > found that scheduled tasks in previous versions of backgroundrb would
> > > not run if the worker scheduled before it was still running.  This
> > > seemed counterintuitive to me (given the whole idea behind
> > > backgroundrb) but after reading documentation and forums, it seems
> > > many others ran into this issue too.  RC2 planned to do away with
> > > this.
> > >
> > > The Good:
> > >
> > > - (Still) Easy Installattion
> > > - Well designed.  Logging is centralized, that's nice.
> > > - Easy to hack up for use in an enterprise environment.
> > >
> > > The Bad:
> > >
> > > - Lots of arbitrary changes that I don't quite understand. Different
> > > function names to create workers, new YML formats, different config
> > > files for scheduler.  Would have been great if none of the rails
> > > application-facing stuff changed so the new version could just be
> > > swapped in.
> > > - Logging detail has greatly diminished.  It's difficult to
> > > troubleshoot what's happening when things go wrong.
> > > - For the moment, this seems less stable than the old version.  My
> > > scheduled tasks are bringing down the whole server and I can't tell
> > > why (nothing showing up in the logs). This is why I've abandoned the
> > > upgrade.  The scheduler is working fine for lightweight tasks, but the
> >
> > > long-running ones just bring everything down.  For what it's worth,
> > > the logic for the tasks still lives in my rails models.  The workers
> > > basically just call class methods in the models.  (Truly using this as
> >
> > > a scheduler.)  Perhaps this has something to do with it?
> > > - Documentation and resources for the new version are sparse
> > > (obviously) and seem a little inaccurate.  For example, I learned that
> > > the MiddleMan.ask_worker() method detailed in the docs is actually
> > > called as MiddleMan.ask_work ().
> >
> > I also saw some typos in the documentation and hence fixing them.
> > >
> > > If anyone has any thoughts on what might be going wrong with my
> > > scheduled tasks, that'd be great.  Thanks!
> >
> > There is definitely an exception being thrown in your worker thats not
> > handled. if possible, please wrap your worker method in a begin rescue
> > and see what happens. Currently, before daemonizing workers, i am
> > redirecting their STDOUT,STDIN and STDERR to a file, so as unhandled
> > exceptions gets logged. I will get this better. Long running schedulers
> > are most important thing and hence any bug will be fixed with atmost
> > care.
> >
> > Also, regarding multi tasksing that you want to achieve. New release of
> > bdrb basically encourages cooperative multitasking not preemtpive
> > multitasking of threads.I will code some examples for this.
> >
> > Thanks for your patience and please try the fix i suggested.
> >
> >
> >
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20071206/edfafb6d/attachment-0001.html 


More information about the Backgroundrb-devel mailing list