Clare
2006-Aug-26 15:28 UTC
[Ferret-talk] Erratic behavior with ferret 0.95 and acts_as_ferret
I am getting this issue also... Does anyone know what this is? When will Acts as Ferret be available for v10? Thanks for your help in desperation! Caspar wrote:> Okay previous post related to me trying to fix this problem with an > upgrade to ferret 0.10.0 but acts as ferret is obviously not compatible > with this new version of ferret. > My app is about to go into production and Ferret acting wierdly is a > major problem. It seems to crash randomly. Below is a list of the > Lighttpd error logs and a selection of code that sometimes produces > errors and sometimes doesn''t even with the same input. > > Would dearly love for ferret to play nice and consistently. > > On the development log of rails i also get stuff like > > *** glibc detected *** corrupted double-linked list: 0x08aa20e0 *** > >-- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2006-Aug-26 15:46 UTC
[Ferret-talk] Erratic behavior with ferret 0.95 and acts_as_ferret
On Sat, Aug 26, 2006 at 05:28:25PM +0200, Clare wrote:> I am getting this issue also... Does anyone know what this is? When will > Acts as Ferret be available for v10?the current svn trunk of the plugin is compatible to acts_as_ferret, besides more_like_this not working and queries not being ANDed by default. You should give this a try if you experience these problems with 0.9.5 Jens> > Thanks for your help in desperation! > > Caspar wrote: > > Okay previous post related to me trying to fix this problem with an > > upgrade to ferret 0.10.0 but acts as ferret is obviously not compatible > > with this new version of ferret. > > My app is about to go into production and Ferret acting wierdly is a > > major problem. It seems to crash randomly. Below is a list of the > > Lighttpd error logs and a selection of code that sometimes produces > > errors and sometimes doesn''t even with the same input. > > > > Would dearly love for ferret to play nice and consistently. > > > > On the development log of rails i also get stuff like > > > > *** glibc detected *** corrupted double-linked list: 0x08aa20e0 *** > > > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk-- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
Hello, I''m using acts_as_ferret with a single model class in my rails app. I have a cron job that batch-loads several hundred objects of this class at a time. While the batch job is running, attempting to run a search from the web app results in a lock error of one type or another. So far I''ve seen the two types of errors below. I see in the archives several messages suggesting that using :auto_flush => true should resolve locking problems. Looking at the acts_as_ferret code suggests to me that :auto_flush => true is being used, but I''m not 100% sure. Can someone shed some light on this for me? I''m using ferret 0.10.1 and acts_as_ferret from svn trunk rev 84. Thanks, -Dave /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/index.rb: 409:in `close'': Lock Error occured at <except.c>:79 in xraise (Ferret::Store::Lock::LockError) Error occured in index.c:5237 - iw_flush_ram_segment Couldn''t obtain commit lock to write segments file from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ ferret/index.rb:409:in `flush'' from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ ferret/index.rb:406:in `flush'' from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ ferret/index.rb:214:in `<<'' from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ ferret/index.rb:186:in `<<'' from /home/digest/digest.sialia.com/helper_scripts/../ config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:567:in `ferret_create'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ lib/active_record/callbacks.rb:344:in `callback'' ... 11 levels... from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ lib/active_record/transactions.rb:126:in `save'' /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/index.rb: 98:in `initialize'': Lock Error occured at <except.c>:103 in xpop_context (Ferret::Store::Lock::LockError) Error occured in index.c:5371 - iw_open Couldn''t obtain write lock when opening IndexWriter from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ ferret/index.rb:98:in `initialize'' from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ ferret/index.rb:96:in `initialize'' from /home/digest/digest.sialia.com/helper_scripts/../ config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:320:in `create_index_instance'' from /home/digest/digest.sialia.com/helper_scripts/../ config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:312:in `ferret_index'' from /home/digest/digest.sialia.com/helper_scripts/../ config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:567:in `ferret_create'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ lib/active_record/callbacks.rb:344:in `callback'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ lib/active_record/callbacks.rb:341:in `callback'' ... 10 levels... from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ lib/active_record/transactions.rb:126:in `save''
On Sat, Aug 26, 2006 at 09:08:46AM -0700, David Ranney wrote:> Hello, > > I''m using acts_as_ferret with a single model class in my rails app. I > have a cron job that batch-loads several hundred objects of this > class at a time. While the batch job is running, attempting to run a > search from the web app results in a lock error of one type or > another. So far I''ve seen the two types of errors below. I see in the > archives several messages suggesting that using :auto_flush => true > should resolve locking problems. Looking at the acts_as_ferret code > suggests to me that :auto_flush => true is being used, but I''m not > 100% sure. Can someone shed some light on this for me?Yes, aaf uses auto_flush. In theory, searching the index should not result in any write access to the index (unless the index doesn''t exist yet, in that case aaf tries to rebuild it before running the search) Where do you see these errors ? The importer script or the web app ? The second stack trace is strange, as the simple initialization of the Index instance results in a locking error. Jens> > I''m using ferret 0.10.1 and acts_as_ferret from svn trunk rev 84. > > Thanks, > > -Dave > > /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/index.rb: > 409:in `close'': Lock Error occured at <except.c>:79 in xraise > (Ferret::Store::Lock::LockError) > Error occured in index.c:5237 - iw_flush_ram_segment > Couldn''t obtain commit lock to write segments file > > from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ > ferret/index.rb:409:in `flush'' > from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' > from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ > ferret/index.rb:406:in `flush'' > from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ > ferret/index.rb:214:in `<<'' > from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' > from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ > ferret/index.rb:186:in `<<'' > from /home/digest/digest.sialia.com/helper_scripts/../ > config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:567:in > `ferret_create'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ > lib/active_record/callbacks.rb:344:in `callback'' > ... 11 levels... > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ > lib/active_record/transactions.rb:126:in `save'' > > > /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/index.rb: > 98:in `initialize'': Lock Error occured at <except.c>:103 in > xpop_context (Ferret::Store::Lock::LockError) > Error occured in index.c:5371 - iw_open > Couldn''t obtain write lock when opening IndexWriter > > from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ > ferret/index.rb:98:in `initialize'' > from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' > from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ > ferret/index.rb:96:in `initialize'' > from /home/digest/digest.sialia.com/helper_scripts/../ > config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:320:in > `create_index_instance'' > from /home/digest/digest.sialia.com/helper_scripts/../ > config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:312:in > `ferret_index'' > from /home/digest/digest.sialia.com/helper_scripts/../ > config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:567:in > `ferret_create'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ > lib/active_record/callbacks.rb:344:in `callback'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ > lib/active_record/callbacks.rb:341:in `callback'' > ... 10 levels... > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ > lib/active_record/transactions.rb:126:in `save'' > > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk-- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
Jens, Thanks for your response. I see errors in either the importer (batch) script or in the web app. The traces I happened to post previously were both from the batch script. Here are the relevant lines from a typical error found in the rails app''s error log. -Dave ActionView::TemplateError (Lock Error occured at <except.c>:79 in xraise Error occured in index.c:3089 - ir_is_latest Error trying to commit the index. Commit lock already obtained ) on line #2 of app/views/messages/_message_tables_simple.rhtml: 1: <% if search_term %> 2: <% messages = Message.find_by_search_term(params[:search_term], session[:timezone_offset]) %> 3: <% elsif current_filter("filter_name") %> 4: <% messages = Message.find_by_current_filter(session ["current_filter"], nil, nil, session[:timezone_offset], params [:days_ago], params[:alldays]) %> 5: <% elsif params["listid"] %> /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/ index.rb:537:in `latest?'' /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/ index.rb:537:in `ensure_reader_open'' /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/ index.rb:264:in `[]'' /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/ index.rb:263:in `[]'' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/ acts_as_ferret.rb:486:in `find_id_by_contents'' /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/ index.rb:252:in `search_each'' /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/ index.rb:251:in `search_each'' /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/ index.rb:247:in `search_each'' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/ acts_as_ferret.rb:484:in `find_id_by_contents'' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/ acts_as_ferret.rb:344:in `find_by_contents'' #{RAILS_ROOT}/app/models/message.rb:87:in `find_by_search_term'' On Aug 27, 2006, at 4:58 AM, Jens Kraemer wrote:> On Sat, Aug 26, 2006 at 09:08:46AM -0700, David Ranney wrote: >> Hello, >> >> I''m using acts_as_ferret with a single model class in my rails app. I >> have a cron job that batch-loads several hundred objects of this >> class at a time. While the batch job is running, attempting to run a >> search from the web app results in a lock error of one type or >> another. So far I''ve seen the two types of errors below. I see in the >> archives several messages suggesting that using :auto_flush => true >> should resolve locking problems. Looking at the acts_as_ferret code >> suggests to me that :auto_flush => true is being used, but I''m not >> 100% sure. Can someone shed some light on this for me? > > Yes, aaf uses auto_flush. In theory, searching the index should not > result in any write access to the index (unless the index doesn''t > exist > yet, in that case aaf tries to rebuild it before running the search) > > Where do you see these errors ? The importer script or the web app ? > > The second stack trace is strange, as the simple initialization of the > Index instance results in a locking error. > > > Jens >> >> I''m using ferret 0.10.1 and acts_as_ferret from svn trunk rev 84. >> >> Thanks, >> >> -Dave >> >> /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/index.rb: >> 409:in `close'': Lock Error occured at <except.c>:79 in xraise >> (Ferret::Store::Lock::LockError) >> Error occured in index.c:5237 - iw_flush_ram_segment >> Couldn''t obtain commit lock to write segments file >> >> from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ >> ferret/index.rb:409:in `flush'' >> from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' >> from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ >> ferret/index.rb:406:in `flush'' >> from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ >> ferret/index.rb:214:in `<<'' >> from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' >> from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ >> ferret/index.rb:186:in `<<'' >> from /home/digest/digest.sialia.com/helper_scripts/../ >> config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:567:in >> `ferret_create'' >> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ >> lib/active_record/callbacks.rb:344:in `callback'' >> ... 11 levels... >> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ >> lib/active_record/transactions.rb:126:in `save'' >> >> >> /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ferret/index.rb: >> 98:in `initialize'': Lock Error occured at <except.c>:103 in >> xpop_context (Ferret::Store::Lock::LockError) >> Error occured in index.c:5371 - iw_open >> Couldn''t obtain write lock when opening IndexWriter >> >> from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ >> ferret/index.rb:98:in `initialize'' >> from /usr/local/lib/ruby/1.8/monitor.rb:229:in `synchronize'' >> from /usr/local/lib/ruby/gems/1.8/gems/ferret-0.10.1/lib/ >> ferret/index.rb:96:in `initialize'' >> from /home/digest/digest.sialia.com/helper_scripts/../ >> config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:320:in >> `create_index_instance'' >> from /home/digest/digest.sialia.com/helper_scripts/../ >> config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:312:in >> `ferret_index'' >> from /home/digest/digest.sialia.com/helper_scripts/../ >> config/../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:567:in >> `ferret_create'' >> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ >> lib/active_record/callbacks.rb:344:in `callback'' >> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ >> lib/active_record/callbacks.rb:341:in `callback'' >> ... 10 levels... >> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/ >> lib/active_record/transactions.rb:126:in `save'' >> >> _______________________________________________ >> Ferret-talk mailing list >> Ferret-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ferret-talk > > -- > webit! Gesellschaft f?r neue Medien mbH www.webit.de > Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de > Schnorrstra?e 76 Tel +49 351 46766 0 > D-01069 Dresden Fax +49 351 46766 66 > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk
On Mon, Aug 28, 2006 at 01:20:29AM -0700, David Ranney wrote:> Jens, > > Thanks for your response. I see errors in either the importer (batch) > script or in the web app. The traces I happened to post previously > were both from the batch script. Here are the relevant lines from a > typical error found in the rails app''s error log. > > -Dave > > ActionView::TemplateError (Lock Error occured at <except.c>:79 in xraise > Error occured in index.c:3089 - ir_is_latest > Error trying to commit the index. Commit lock already obtainedok, it seems that the check to see if the current IndexReader is based on the latest version of the Ferret index wants to obtain a write lock and fails, since the batch indexing job already has locked it. This check is done by the Ferret::Index::Index class before every search. Maybe Dave could shed some light on how to handle these errors ? Imho Ferret should retry some more times to obtain a lock before failing that way. As a short term fix, one could catch the lock error in Ferret::Index::Index#ensure_reader_open and continue as if index_reader.latest? had returned true. That would prevent the search from failure due to a locked index. In the opposite direction, i.e. if latest? grabbed the lock and the indexing failed, a simple retry (calling record.save another time) could solve the problem, too. Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
Jens, Thanks again, that makes sense. I''ll implement some workarounds in my code until we hear from Dave on the matter. -Dave On Aug 28, 2006, at 3:20 AM, Jens Kraemer wrote:> On Mon, Aug 28, 2006 at 01:20:29AM -0700, David Ranney wrote: >> Jens, >> >> Thanks for your response. I see errors in either the importer (batch) >> script or in the web app. The traces I happened to post previously >> were both from the batch script. Here are the relevant lines from a >> typical error found in the rails app''s error log. >> >> -Dave >> >> ActionView::TemplateError (Lock Error occured at <except.c>:79 in >> xraise >> Error occured in index.c:3089 - ir_is_latest >> Error trying to commit the index. Commit lock already >> obtained > > ok, it seems that the check to see if the current IndexReader is > based on > the latest version of the Ferret index wants to obtain a write lock > and > fails, since the batch indexing job already has locked it. > > This check is done by the Ferret::Index::Index class before every > search. Maybe Dave could shed some light on how to handle these > errors ? > Imho Ferret should retry some more times to obtain a lock before > failing > that way. > > As a short term fix, one could catch the lock error in > Ferret::Index::Index#ensure_reader_open and continue as if > index_reader.latest? > had returned true. That would prevent the search from failure due to > a locked index. > > In the opposite direction, i.e. if latest? grabbed the lock and the > indexing failed, a simple retry (calling record.save another time) > could > solve the problem, too. > > Jens > > > -- > webit! Gesellschaft f?r neue Medien mbH www.webit.de > Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de > Schnorrstra?e 76 Tel +49 351 46766 0 > D-01069 Dresden Fax +49 351 46766 66 > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk
On 8/29/06, David Ranney <dave at sialia.com> wrote:> Jens, > > Thanks again, that makes sense. I''ll implement some workarounds in my > code until we hear from Dave on the matter.Hey Dave, I''ve added a small sleep to the lock-obtain loop which should fix this problem. There is also a single 2 second sleep and retry in the Index class (you can change this with the :lock_retry_time parameter). Please let me know whether or not this works for you. It''s already in the subversion repository and it''ll be out in version 0.10.2. Cheers, Dave