Infinite loop in will_paginate with has_many :through
Reported by Nate Wiger | May 22nd, 2008 @ 12:04 AM
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 June 11th, 2008 @ 02:13 PM
- 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 July 19th, 2008 @ 11: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 20th, 2008 @ 08:23 AM
Actually, this problem went away after I updated to mislav-will_paginate. Sidu, I suggest you try the same.
-
Mislav August 9th, 2008 @ 11:03 AM
Nate Wiger: are you using any plugins that hook into ActiveRecord?
-
David Eisinger August 25th, 2008 @ 04:21 PM
I was experiencing this behavior. Upgrading my app from 2.0.2 to 2.1.0 fixed it for me.
-
FotoVerite September 20th, 2008 @ 09: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 @ 01:19 PM
- 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 January 10th, 2013 @ 03:22 PM
- State changed from hold to resolved
(from [6d35492963eb2e8fb6683120112cb65afaae513d]) fix
first
for 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...