lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless" <luc...@mikemccandless.com>
Subject RE: IndexWriter shutdown
Date Wed, 23 May 2007 17:12:03 GMT
"Doron Cohen" <DORONC@il.ibm.com> wrote:
> Michael McCandless wrote on 23/May/2007:
> 
> > Actually if autoCommit=true then the only choice is to keep
> > the partial work.  In this mode, optimize indeed goes in
> > "stages" (merging mergeFactor segments at a time) and after
> > each stage it commits a new segments_N file and removes the
> > now-merged segments.  Of course if it's a smallish index
> > (<= mergeFactor segments) then there is only 1
> > stage anyway.
> >
> > If autoCommit=false, then I think the index should rollback
> > to the state when the IndexWriter was opened.  This is the
> > point of autoCommit=false: either all or none of the changes
> > made during the lifetime of the IndexWriter instance
> > "make it" into the index.
> 
> Just to clarify - so this would just "happen by itself", because
> (if autoCommit is implemented as I think), the new Segments_N
> file is written only upon a completed commit. So whenever we
> stop due to shutdown, fully committed merges are already saved,
> interrupted ones are "lost" (as expected). Right?

That's correct.

On seeing the "shutdown in progress" exception, the current "finally"
clause in mergeSegments would revert the internal state of the
IndexWriter to be consistent, ie, put back the segments that were in
the process of being merged into its segmentInfos.  It will also
remove any partially created but now unusable newly merged segments
files.

If the application catches this exception and calls
IndexWriter.close(), then the state until just before the aborted
merge would be committed to the index.  If instead the application
catches the exception and does nothing, then the state of the index
reverts back to where it was when this IndexWriter instance was first
opened.

So the semantics of autoCommit=false will be correctly enforced if any
exception (not just this new one) comes up through mergeSegments.

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message