You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Ryan McKinley <ry...@gmail.com> on 2007/02/18 09:29:03 UTC

autocommit bug

found one that is my fault!

If you commit a document while the updater is autocommiting, it is
likely to immediatly start another autocommit (unless you are also
using maxDocs).

Here is the one line patch to fix it:


Index: DirectUpdateHandler2.java
===================================================================
--- DirectUpdateHandler2.java	(revision 508885)
+++ DirectUpdateHandler2.java	(working copy)
@@ -640,7 +640,7 @@

       // check if docs have been submitted since the commit started
       if( lastAddedTime > started ) {
-        if( docsSinceCommit > docsUpperBound ) {
+        if( docsUpperBound > 0 && docsSinceCommit > docsUpperBound ) {
           pending = scheduler.schedule( this, 100, TimeUnit.MILLISECONDS );
         }
         else if( timeUpperBound > 0 ) {

Re: autocommit bug

Posted by Mike Klaas <mi...@gmail.com>.
On 2/19/07, Ryan McKinley <ry...@gmail.com> wrote:
> On 2/19/07, Chris Hostetter <ho...@fucit.org> wrote:
> >
> > : If you commit a document while the updater is autocommiting, it is
> > : likely to immediatly start another autocommit (unless you are also
> > : using maxDocs).
> >
> > i don't really understand how the autocommit stuff is safe from
> > concurency issues...

AutoCommit is protected by the iwCommit lock, which is mutually
exclusive with the iwAccess lock.  If a commit is occurring, addDoc()
calls should block on acquiring the latter lock.

> tracker.addedDocument() is only called from the synchronized block
> within updateHandler.addDoc(AddUpdateCommand cmd);
>
> it is called between
>   iwAccess.lock();
> and
>   iwAccess.unlock();
>
> That should make sure it is not started more then once.  (java
> threading and concurrency still feels a little like voodoo, so I could
> be missing something)

iwAccess is not a self-exclusive lock, so this would not be sufficient
protection.  However, the autocommit stuff _is_ called within a
synchronized block in that method (which is partly what the extra
synchronization is there for).

Thanks for looking at this before I got the chance, Hoss.

-Mike

Re: autocommit bug

Posted by Ryan McKinley <ry...@gmail.com>.
On 2/19/07, Chris Hostetter <ho...@fucit.org> wrote:
>
> : If you commit a document while the updater is autocommiting, it is
> : likely to immediatly start another autocommit (unless you are also
> : using maxDocs).
>
> i don't really understand how the autocommit stuff is safe from
> concurency issues...

tracker.addedDocument() is only called from the synchronized block
within updateHandler.addDoc(AddUpdateCommand cmd);

it is called between
  iwAccess.lock();
and
  iwAccess.unlock();

That should make sure it is not started more then once.  (java
threading and concurrency still feels a little like voodoo, so I could
be missing something)


> but i certianly couldn't see any way this would cause any problems, so i've commited it.
>

thanks

Re: autocommit bug

Posted by Chris Hostetter <ho...@fucit.org>.
: If you commit a document while the updater is autocommiting, it is
: likely to immediatly start another autocommit (unless you are also
: using maxDocs).

i don't really understand how the autocommit stuff is safe from
concurency issues... but i certianly couldn't see any way this would cause
any problems, so i've commited it.



-Hoss