You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2020/06/24 16:50:31 UTC
[lucene-solr] 02/07: add failing test for carry-over deletes
This is an automated email from the ASF dual-hosted git repository.
simonw pushed a commit to branch jira/lucene-8962
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit c29875f964deb4cd04d88ac9b357f0fa0e615237
Author: Simon Willnauer <si...@apache.org>
AuthorDate: Tue Jun 23 08:56:42 2020 +0200
add failing test for carry-over deletes
---
.../lucene/index/TestIndexWriterMergePolicy.java | 47 ++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
index 2577f6b..08222ef 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
@@ -20,10 +20,12 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
@@ -363,4 +365,49 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// TODO: Add more checks for other non-double setters!
}
+
+ public void testCarryOverNewDeletes() throws IOException, InterruptedException {
+ try (Directory directory = newDirectory()) {
+ CountDownLatch waitForMerge = new CountDownLatch(1);
+ CountDownLatch waitForUpdate = new CountDownLatch(1);
+ try (IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig()
+ .setMergePolicy(MERGE_ON_COMMIT_POLICY).setMaxCommitMergeWaitSeconds(30)
+ .setMergeScheduler(new ConcurrentMergeScheduler())) {
+ @Override
+ protected void merge(MergePolicy.OneMerge merge) throws IOException {
+ waitForMerge.countDown();
+ try {
+ waitForUpdate.await();
+ } catch (InterruptedException e) {
+ throw new AssertionError(e);
+ }
+ super.merge(merge);
+ }
+ }) {
+ Document d1 = new Document();
+ d1.add(new StringField("id", "1", Field.Store.NO));
+ Document d2 = new Document();
+ d2.add(new StringField("id", "2", Field.Store.NO));
+ writer.addDocument(d1);
+ writer.flush();
+ writer.addDocument(d2);
+ Thread t = new Thread(() -> {
+ try {
+ waitForMerge.await();
+ writer.updateDocument(new Term("id", "2"), d2);
+ writer.flush();
+ waitForUpdate.countDown();
+ } catch (Exception e) {
+ throw new AssertionError(e);
+ }
+ });
+ t.start();
+ writer.commit();
+ t.join();
+ try (DirectoryReader open = DirectoryReader.open(directory)) {
+ assertEquals(2, open.numDocs());
+ }
+ }
+ }
+ }
}