Arvind Srinivasan wrote:
Some options are:
(1)Commit the counter after the newSegmentName call. This way we never reuse the
the segmentName.
(2) Add a callback API to directory interface for a new Segment Creation
allowing
the directory interface to clean up, on a new segment write.
(3) Provide a Rollback mechanism in the event of merge failure. (Using the
deleteable
functionality).
(4) For Compound File Store (The file must be empty). (Possibly, it can use the callback
in (2) to cleanup.
I think the fix is much simpler. This is a bug in FSDirectory.
Directory.createOutput() should always create a new empty file, and
FSDirectory's implementation does not ensure this. It should try to
delete the file before opening it and/or call RandomAccessFile.setLength(0).
I've attached a patch. Does this fix things for you?
Doug
Index: src/java/org/apache/lucene/store/FSDirectory.java
===================================================================
--- src/java/org/apache/lucene/store/FSDirectory.java (revision 178648)
+++ src/java/org/apache/lucene/store/FSDirectory.java (working copy)
@@ -306,6 +306,7 @@
/** Creates a new, empty file in the directory with the given name.
Returns a stream writing this file. */
public IndexOutput createOutput(String name) throws IOException {
+ deleteFile(name); // first delete any existing
return new FSIndexOutput(new File(directory, name));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]