Infinite loop in will_paginate with has_many :through
Reported by Nate Wiger | 2008-05-22 00:04:27 UTC
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
-

Mislav 2008-06-11 14:13:06 UTC
- 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/
-

Sidu Ponnappa 2008-07-19 23:40:25 UTC
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 2008-07-20 08:23:29 UTC
Actually, this problem went away after I updated to mislav-will_paginate. Sidu, I suggest you try the same.
-

-

David Eisinger 2008-08-25 16:21:01 UTC
I was experiencing this behavior. Upgrading my app from 2.0.2 to 2.1.0 fixed it for me.
-

FotoVerite 2008-09-20 09:10:53 UTC
- 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 2008-10-07 13:19:58 UTC
- 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
-

Mislav 2013-01-10 15:22:54 UTC
- State changed from hold to resolved
(from [6d35492963eb2e8fb6683120112cb65afaae513d]) fix
firstfor paginated AR RelationsFixes #223
https://github.com/mislav/will_paginate/commit/6d35492963eb2e8fb668...
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Everyone's favorite Ruby library for pagination of practically anything!
People watching this ticket
Tags
Referenced by
-
220
has many :through causes "Stack level too deep error"
Please make comments on #223.
-
220
has many :through causes "Stack level too deep error"
If you could recreate the error in a blank
Rails applicat...