Hello everyone,

I was stress-testing my application (running on Rails via FastCGI) by 
letting two concurrent users (not human .. an app called 'siege')
a) save an Article and b) search for all Articles.

I am searching via
   Article.ferret_index.search_each( ..) do |doc_id,score|
     doc = index[doc_id]
     ..
   end

and writing via
   Article.ferret_index << self.to_doc

where Article.ferret_index is implemented as in 'act_as_ferret':
  @@ferret_index = nil
  def Article::ferret_index
    @@ferret_index ||= Ferret::Index::Index.new( :path => ferret_path, 
:auto_flush => true, :create_if_missing => false )
  end

The 2 errors I got (when I do "doc = index[doc_id]") were :
ArgumentError (:12250 is out of range [0..12243] for IndexWriter#[]):
    /usr/lib/ruby/gems/1.8/gems/ferret-0.10.8/lib/ferret/index.rb:382:in 
`[]'
    /usr/lib/ruby/gems/1.8/gems/ferret-0.10.8/lib/ferret/index.rb:382:in 
`[]'
    /usr/lib/ruby/1.8/monitor.rb:229:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/ferret-0.10.8/lib/ferret/index.rb:375:in 
`[]'
    ...

Ferret::StateError (State Error occured at <except.c>:79 in xraise
Error occured in index.c:3404 - sr_get_lazy_doc
  Document 0 has already been deleted

):
    /usr/lib/ruby/gems/1.8/gems/ferret-0.10.8/lib/ferret/index.rb:382:in 
`[]'
    /usr/lib/ruby/gems/1.8/gems/ferret-0.10.8/lib/ferret/index.rb:382:in 
`[]'
    /usr/lib/ruby/1.8/monitor.rb:229:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/ferret-0.10.8/lib/ferret/index.rb:375:in 
`[]'
   ...

So, obviously the index changed after #search_each and before "doc = 
index[doc_id]".
Is this expected behaviour? How to avoid this?

Then I did the same thing without a webserver, just 2 consoles. One for 
saving, one for searching.
The one searching now just ends with 
"/usr/lib/ruby/gems/1.8/gems/ferret-0.10.8/lib/ferret/index.rb:363: 
[BUG] Segmentation fault"

As for now, to avoid the problem, I use an IndexReader that I newly 
create for every search.
But I guess that is not the best approach?

I am using ferret 0.10.8 and ruby 1.8.4 on Debian Sarge.


Best regards

josh

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
Ferret-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to