prepareCommit flushes any buffered docs (in RAM) to a new segment, applies all deletes, fsync's the new files, writes all but the last 4 checksum bytes of the segments file.
Ie, it tries to do everything possible short of finishing the commit up front, so that if there will be a problem, e.g. disk full, you should hit it during prepareCommit. But, an external reader opening the index at this point will still not see the commit. Then, commit writes the last 4 checksum bytes, closes the segments file and syncs it, so that the commit is now visible to any newly opened reader. Any indexing requests that arrive while a commit is underway may or may not make it into the commit; it depends how the threads are scheduled. If they don't make it into the commit then they will just be buffered up for the next commit. Lucene still writes segment files when commit is not called, e.g. when the RAM buffer is full. Mike McCandless http://blog.mikemccandless.com On Wed, Oct 16, 2013 at 11:37 AM, Phani Chaitanya <pvempaty....@gmail.com> wrote: > Hi all, > > I'd like to know a bit more in detail about what is happening behind the > scenes in case of prepareCommit vs Commit. > > Also, I read that if a indexing request comes while commit is requested, it > opens a new segment for the indexing and commit happens as usual. So, the > question is when would a new segment be opened for indexing ? Is it part of > prepareCommit/Commit ? If so, why ? > > Thanks. > > > > ----- > Phani Chaitanya > -- > View this message in context: > http://lucene.472066.n3.nabble.com/prepareCommit-vs-Commit-tp4095917.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org