Infinite loop in will_paginate with has_many :through
Reported by Nate Wiger | May 21st, 2008 @ 03:04 PM
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
Comments and changes to this ticket
-
Nate Wiger May 21st, 2008 @ 03:06 PM
*CORRECTION*: I was mistaken. Leaving off the :include does not affect the problem in any way.
-
Mislav June 11th, 2008 @ 05:13 AM
- → Assigned user changed from Chris Wanstrath to Mislav
- → State changed from new to open
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/
-
Nate Wiger June 25th, 2008 @ 10:57 AM
- → Tag changed from 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
-
vamsee July 2nd, 2008 @ 12:36 AM
Confirming this bug - gives a "stack level too deep" error in combination with acts_as_taggable plugin.
-

Sidu Ponnappa July 19th, 2008 @ 02:40 PM
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'
-
vamsee July 19th, 2008 @ 11:23 PM
Actually, this problem went away after I updated to mislav-will_paginate. Sidu, I suggest you try the same.
-
Mislav August 9th, 2008 @ 02:03 AM
Nate Wiger: are you using any plugins that hook into ActiveRecord?
-
David Eisinger August 25th, 2008 @ 07:21 AM
I was experiencing this behavior. Upgrading my app from 2.0.2 to 2.1.0 fixed it for me.
-

FotoVerite September 20th, 2008 @ 12:10 AM
- → 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.
-
Mislav October 7th, 2008 @ 04:20 AM
- → 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
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
