[Backgroundrb-devel] [SOLVED] Re: BgDRb initializes my models twice?

hemant gethemant at gmail.com
Wed Feb 27 21:00:05 EST 2008


On Wed, Feb 27, 2008 at 6:59 PM, Michael Siebert
<siebertm85 at googlemail.com> wrote:
> I got it. MasterProxy#load_rails_models loaded all models, which seems
>  to be wrong. for our application, i commented out the call to
>  load_rails_models and everything worked fine.
>
>  but we should ask ourselves if it is nesseccary to load the rails
>  models for master_proxy. it doesnt use it and in the worker processes,
>  rails autoloader could load them as well.
>
>  greetings,
>  micha
>  Am 27.02.2008 um 14:11 schrieb Michael Siebert:
>
>
>
>  > Hello there,
>  >
>  > I've stumbled into a phenomenon: my models get loaded twice (or
>  > more). Best thing would be describing my setup:
>  >
>  > I have a Folder model using acts_as_taggable (from
>  > acts_as_taggable_on_steroids) in the acts_as_taggable class method
>  > being calledon initialization, it does the following:
>  >
>  >> alias_method_chain :reload, :tag_list
>  >
>  >
>  > Now, when something (namely better_nested_set) calls self.reload,
>  > reload_with_tag_list is called which in turn calls
>  > reload_without_tag_list (which is the original one). This is how it
>  > should work and how it works in rails context.
>  >
>  > when i now start backgroundrb and self.reload is called, i get:
>  >
>  >> #<SystemStackError: stack level too deep>
>  >> /Users/micha/rails/dmt/trunk/vendor/plugins/
>  >> acts_as_taggable_on_steroids/lib/acts_as_taggable.rb:192:in
>  >> `reload_without_tag_list'
>  >> /Users/micha/rails/dmt/trunk/vendor/plugins/
>  >> acts_as_taggable_on_steroids/lib/acts_as_taggable.rb:192:in `reload'
>  >> /Users/micha/rails/dmt/trunk/vendor/plugins/betternestedset/lib/
>  >> better_nested_set.rb:430:in `move_to'
>  >> /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
>  >> connection_adapters/abstract/database_statements.rb:66:in
>  >> `transaction'
>  >> /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
>  >> transactions.rb:80:in `transaction'
>  >> /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
>  >> transactions.rb:100:in `transaction'
>  >> /Users/micha/rails/dmt/trunk/vendor/plugins/betternestedset/lib/
>  >> better_nested_set.rb:429:in `move_to'
>  >> /Users/micha/rails/dmt/trunk/vendor/plugins/betternestedset/lib/
>  >> better_nested_set.rb:421:in `move_to_child_of'
>  >> /Users/micha/rails/dmt/trunk/lib/workers/processing_queue_worker.rb:
>  >> 194:in `process_convert_pdf'
>  >> /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
>  >> connection_adapters/abstract/database_statements.rb:66:in
>  >> `transaction'
>  >> /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
>  >> transactions.rb:80:in `transaction'
>  >> /Users/micha/rails/dmt/trunk/lib/workers/processing_queue_worker.rb:
>  >> 191:in `process_convert_pdf'
>  >
>  > with ruby-debug, i can see that acts_as_taggable is called more then
>  > once, doing the alias_method_chain more than once, too, so that
>  > reload_with_tag_list calls reload_with_taglist which calls
>  > reload_with_tag_list. if you don't understand that, try to sketch
>  > it :)
>  >
>  > is this behaviour known, is it a bug or superman?
>  >

Prolly superman, but this is a know problem and hence in version
available from git ( or svn trunk also ), has an option

:lazy_load false, which will disable loading of models in master process.


More information about the Backgroundrb-devel mailing list