autocommit bug

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

autocommit bug

Ryan McKinley
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 ) {
Reply | Threaded
Open this post in threaded view
|

Re: autocommit bug

Chris Hostetter-3

: 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

Reply | Threaded
Open this post in threaded view
|

Re: autocommit bug

Ryan McKinley
On 2/19/07, Chris Hostetter <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: autocommit bug

Mike Klaas
On 2/19/07, Ryan McKinley <[hidden email]> wrote:
> On 2/19/07, Chris Hostetter <[hidden email]> 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