lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r415808 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/store/FSDirectory.java
Date Tue, 20 Jun 2006 21:28:42 GMT
Author: yonik
Date: Tue Jun 20 14:28:42 2006
New Revision: 415808

URL: http://svn.apache.org/viewvc?rev=415808&view=rev
Log:
truncate new segment files before use: LUCENE-415

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=415808&r1=415807&r2=415808&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Jun 20 14:28:42 2006
@@ -47,6 +47,10 @@
 
  8. LUCENE-607: ParallelReader's TermEnum fails to advance properly to
     new fields (Chuck Williams, Christian Kohlschuetter via Yonik Seeley)
+
+ 9. LUCENE-415: A previously unclean shutdown during indexing can cause
+    a non-empty segment file to be re-used, causing index corruption.
+    (Andy Hind via Yonik Seeley)
         
 Optimizations
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java?rev=415808&r1=415807&r2=415808&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java Tue Jun 20 14:28:42
2006
@@ -496,6 +496,13 @@
 
   public FSIndexOutput(File path) throws IOException {
     file = new RandomAccessFile(path, "rw");
+    if (file.length() == 0) {
+      // This can happen if there was a previous crash / unclean shutdown that
+      // left files around, then we end up re-using a segment name.
+      // If we have a logging framework in the future, a warning here might be
+      // a good idea.
+      file.setLength(0);
+    }
   }
 
   /** output methods: */



Mime
View raw message