Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Infinite loop in will_paginate with has_many :through

#223

We are having the infinite loop with will_paginate as well. This happens with the following set of associations:

   class LobbyChannel < ActiveRecord::Base
     has_many :lobby_channel_players
     has_many :players, :through => :lobby_channel_players
   end

   class LobbyChannelPlayer < ActiveRecord::Base
     belongs_to :lobby_channel
     belongs_to :player
   end

   class Player < ActiveRecord::Base
     has_many :lobby_channel_players
     has_many :lobby_channels, :through => :lobby_channel_players
   end

The find that triggers it is:

    lobby_channel = find(channel_id, :include => [ :players ])

If we leave off the :include, then the issue is not triggered.

The bug we see is Mongrel shoots to 100% CPU in an infinite loop. When you kill the thread, you get this call stack (ignore the "Error reference", that's something our app adds):

[Error reference: 1211400279]     /usr/sdod-rails2/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:221:in `method_missing_without_paginate'
[Error reference: 1211400279]     vendor/plugins/will_paginate/lib/will_paginate/finder.rb:164:in `method_missing'
[Error reference: 1211400279]     /usr/sdod-rails2/lib/ruby/gems/1.8/gems/activerecord-2.0.2.9216/lib/active_record/associations/has_many_through_association.rb:138:in `method_missing_without_paginate'
[Error reference: 1211400279]     vendor/plugins/will_paginate/lib/will_paginate/finder.rb:164:in `method_missing'
[Error reference: 1211400279]     /usr/sdod-rails2/lib/ruby/gems/1.8/gems/activerecord-2.0.2.9216/lib/active_record/associations/has_many_through_association.rb:138:in `method_missing_without_paginate'
[Error reference: 1211400279]     vendor/plugins/will_paginate/lib/will_paginate/finder.rb:164:in `method_missing'
[Error reference: 1211400279]     /usr/sdod-rails2/lib/ruby/gems/1.8/gems/activerecord-2.0.2.9216/lib/active_record/associations/has_many_through_association.rb:138:in `method_missing_without_paginate'

Please let me know if I can help testing this in any way.

Thanks,
Nate

Reported by Nate Wiger · May 22nd, 2008 @ 12:04 AM

State: open
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Nate Wiger
    Nate Wiger

    CORRECTION: I was mistaken. Leaving off the :include does not affect the problem in any way.

    May 22nd, 2008 @ 12:06 AM

  2. Mislav
    Mislav
    • State changed from new to open
    • Assigned user changed from Chris Wanstrath to Mislav

    See #215 and #220. Are you using older version of will_paginate? The newest version is "mislav-will_paginate" 2.3.2 from http://gems.github.com/

    June 11th, 2008 @ 02:13 PM

  3. Nate Wiger
    Nate Wiger
    • Tag set to bug, will_paginate

    I just double-checked, and we are using the latest 2.3.2 from github. This issue is still occurring. If you follow the example above, you should be able to reproduce it. Please let me know if I can provide more help.

    Thanks,
    Nate

    June 25th, 2008 @ 07:57 PM

  4. Sidu Ponnappa
    Sidu Ponnappa

    Confirming this bug for any collection actions (each, select, collect, detect...) for a has many through collection.

    SystemStackError: stack level too deep

    /trunk/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:164:in `method_missing_without_paginate'

    /trunk/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:164:in `method_missing'

    July 19th, 2008 @ 11:40 PM

  5. vamsee
    vamsee

    Actually, this problem went away after I updated to mislav-will_paginate. Sidu, I suggest you try the same.

    July 20th, 2008 @ 08:23 AM

  6. Mislav
    Mislav

    Nate Wiger: are you using any plugins that hook into ActiveRecord?

    August 9th, 2008 @ 11:03 AM

  7. David Eisinger
    David Eisinger

    I was experiencing this behavior. Upgrading my app from 2.0.2 to 2.1.0 fixed it for me.

    August 25th, 2008 @ 04:21 PM

  8. FotoVerite
    FotoVerite
    • Tag changed from bug, will_paginate to bug, will_paginate

    Experiencing this also. Using ActiveScaffold so that's probably where the bug is. Why it's even being called for an create method is beyond me though.

    September 20th, 2008 @ 09:10 AM

  9. Mislav
    Mislav
    • State changed from open to hold

    I have tried to reproduce several of these failures (tests in commit de98ac9), but without success. I tested with Rails versions 1.2.6, 2.0.4 and 2.1.0.

    This led me to believe that you guys are experiencing issues because of 3rd party plugins that mix into ActiveRecord obtrusively.

    So, in the next reports I expect you to paste me a list of libraries/plugins you're using. Also make sure that you're on the latest version of "mislav-will_paginate" before submitting a comment.

    Thanks

    October 7th, 2008 @ 01:19 PM

  10. Mislav

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.