mirror of https://github.com/apache/lucene.git
LUCENE-4521: make sure we commit new del file if tryDeleteDocument succeeds but IW has no other pending changes
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1404229 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6c45b24b48
commit
c898b44722
|
@ -104,6 +104,12 @@ Bug Fixes
|
|||
* LUCENE-4511: TermsFilter might return wrong results if a field is not
|
||||
indexed or doesn't exist in the index. (Simon Willnauer)
|
||||
|
||||
* LUCENE-4521: IndexWriter.tryDeleteDocument could return true
|
||||
(successfully deleting the document) but then on IndexWriter
|
||||
close/commit fail to write the new deletions, if no other changes
|
||||
happened in the IndexWriter instance. (Ivan Vasilev via Mike
|
||||
McCandless)
|
||||
|
||||
Optimizations
|
||||
|
||||
* LUCENE-4512: Additional memory savings for CompressingStoredFieldsIndex.MEMORY_CHUNK
|
||||
|
|
|
@ -1317,6 +1317,10 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
|
|||
checkpoint();
|
||||
}
|
||||
}
|
||||
|
||||
// Must bump changeCount so if no other changes
|
||||
// happened, we still commit this change:
|
||||
changeCount++;
|
||||
}
|
||||
//System.out.println(" yes " + info.info.name + " " + docID);
|
||||
return true;
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.lucene.search.TermQuery;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
|
@ -1116,4 +1117,32 @@ public class TestIndexWriterDelete extends LuceneTestCase {
|
|||
assertFalse(s.contains("has deletions"));
|
||||
dir.close();
|
||||
}
|
||||
|
||||
public void testTryDeleteDocument() throws Exception {
|
||||
|
||||
Directory d = newDirectory();
|
||||
|
||||
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||
IndexWriter w = new IndexWriter(d, iwc);
|
||||
Document doc = new Document();
|
||||
w.addDocument(doc);
|
||||
w.addDocument(doc);
|
||||
w.addDocument(doc);
|
||||
w.close();
|
||||
|
||||
iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||
iwc.setOpenMode(IndexWriterConfig.OpenMode.APPEND);
|
||||
w = new IndexWriter(d, iwc);
|
||||
IndexReader r = DirectoryReader.open(w, false);
|
||||
assertTrue(w.tryDeleteDocument(r, 1));
|
||||
assertTrue(w.tryDeleteDocument(r.leaves().get(0).reader(), 0));
|
||||
r.close();
|
||||
w.close();
|
||||
|
||||
r = DirectoryReader.open(d);
|
||||
assertEquals(2, r.numDeletedDocs());
|
||||
assertNotNull(MultiFields.getLiveDocs(r));
|
||||
r.close();
|
||||
d.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue