#223 ✓resolved
Nate Wiger

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

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.

New-ticket Create new ticket

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!

Referenced by

Pages