Issue Details (XML | Word | Printable)

Key: LUCENE-1274
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Michael McCandless
Reporter: Michael McCandless
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

Expose explicit 2-phase commit in IndexWriter

Created: 27/Apr/08 10:46 AM   Updated: 11/Oct/08 12:49 PM
Return to search
Component/s: Index
Affects Version/s: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1
Fix Version/s: 2.4

Time Tracking:
Original Estimate: 336h
Original Estimate - 336h
Remaining Estimate: 336h
Remaining Estimate - 336h
Time Spent: Not Specified
Remaining Estimate - 336h

File Attachments:
  Size
Text File Licensed for inclusion in ASF works LUCENE-1274.patch 2008-04-27 08:33 PM Michael McCandless 39 kB

Lucene Fields: New
Resolution Date: 06/May/08 06:41 PM


 Description  « Hide
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



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael McCandless added a comment - 27/Apr/08 10:47 AM
I plan to rename abort() to rollback() (deprecating abort()), then add
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.

Michael McCandless added a comment - 27/Apr/08 08:33 PM
Attached patch. I plan to commit in a few days.