pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 469 forks source link

stack level too deep problem with 2.0.5 #233

Closed goodsimon closed 12 years ago

goodsimon commented 13 years ago

I'm using thinking-sphinx 2.0.5 and Rails 3.1.0 beta (sorry I'm out there on an edge)...

I have a model using STI with an index defined on an Entity class and another on its sub-class Product

class Entity < ActiveRecord::Base

define_index do indexes :name, :sortable => true end

... etc.

class Product < Entity define_index do indexes :name, :sortable => true indexes ancestors(:name), :as => :ancestor_name end end

where ancestors is an association through a join table that defined entity-entity ancestor-descendent relationships

That all seems to work nicely but when I try to run my existing tests that do nothing with Sphinx and do a call of Product.count I get an exception:

      SystemStackError: stack level too deep
      /home/simon/.rvm/gems/ruby-1.9.2-p0@newapi/gems/thinking-sphinx-2.0.5/lib/thinking_sphinx/search_methods.rb:12

From the script/console command line I get a similar result (except it doesn't give me that line number unless I catch the exception myself).

I can call Entity.count() just fine and get 0 (my test db has no entities by default).

Looking at that code in the TS source it is try to get self.class.name

module ClassMethods def search_context

Comparing to name string to avoid class inheritance complications

--> case self.class.name when 'Class' self else nil end end

This smells like some kind of class loading problem so I tried turning off class caching in test mode and low and behold the problem went away but obviously I need class caching on in production mode (which also has the same problem).

The only other clue I have is if I remove the define_index from Entity that also "solves" the problem although in this instance I do need both indexes (I think) since Product and other subclasses of Entity need different indexes.

Simplifying the Product index doesn't help either - I can remove the ancestor part and I still get the stack explosion. I can also make it just an index on the ancestor and that fails too - so it's not duplicating the index on :name.

Any ideas?

pat commented 13 years ago

I'll need to investigate further - if you care to set up a test 3.1 app which has this problem, that'd certainly make things easier for me - but if you don't have time, no worries, I'll get to it when I can.

pat commented 12 years ago

Finally got around to looking at this, and can't reproduce it, so I'm going to close it. If you can get it erroring in a test app (or even still seeing the same issue with 3.1.0 proper or 3.1.1), let me know.

goodsimon commented 12 years ago

Thanks for having a long memory and looking into this for us - we haven't had a chance to upgrade to the mainstream Rails yet since we had a patch on the beta. But I will look into it when we do and let you know if there are issues.

Thanks again,

Simon.

On Thu, Nov 3, 2011 at 8:55 AM, Pat Allan < reply@reply.github.com>wrote:

Finally got around to looking at this, and can't reproduce it, so I'm going to close it. If you can get it erroring in a test app (or even still seeing the same issue with 3.1.0 proper or 3.1.1), let me know.


Reply to this email directly or view it on GitHub:

https://github.com/freelancing-god/thinking-sphinx/issues/233#issuecomment-2618876

-- Simon Waddington -- (415) 732-7722 x19 (w) || (510) 394-4242 (m) -- www.goodguide.com -- Live your values, change the world!