Currently when IndexWriter commits, it does so with a two-phase
commit, internally: first it prepares all the new index files, syncs
them; then it writes a new segments_N file and syncs that, and only if
that is successful does it remove any now un-referenced index files.
However, these two phases are done privately, internal to the commit()
method.
But when Lucene is involved in a transaction with external resources
(eg a database), it's very useful to explicitly break out the prepare
phase from the commit phase.
Spinoff from this thread:
http://mail-archives.apache.org/mod_mbox/lucene-java-dev/200804.mbox/%3C16627610.post@talk.nabble.com%3E
a new method "prepareCommit()" to IndexWriter. If you call this, then
IndexWriter is left in a mode where a commit is pending. You must
follow this up either with a call to rollback(), which reverts all
changes done since you first opened IndexWriter and closes it, or
commit(), which completes the transaction. prepareCommit() requires
that IndexWriter is opened with autoCommit false.