You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2023/11/14 22:12:09 UTC

(lucene) branch branch_9x updated: New attempt at addressing testHasUncommittedChanges() failures.

This is an automated email from the ASF dual-hosted git repository.

jpountz pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 910c721e065 New attempt at addressing testHasUncommittedChanges() failures.
910c721e065 is described below

commit 910c721e06559496481c1ecb601855739f8ded47
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Tue Nov 14 23:11:06 2023 +0100

    New attempt at addressing testHasUncommittedChanges() failures.
---
 .../org/apache/lucene/index/TestIndexWriter.java     | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
index 72ade33ecf0..a4b70b57beb 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -2373,9 +2373,9 @@ public class TestIndexWriter extends LuceneTestCase {
         new IndexWriter(
             dir,
             newIndexWriterConfig(new MockAnalyzer(random()))
-                // Use a serial merge scheduler to avoid race conditions when checking for
-                // hasPendingMerges()
-                .setMergeScheduler(new SerialMergeScheduler()));
+                // Disable merging to simplify this test, otherwise a commit might trigger
+                // uncommitted merges.
+                .setMergePolicy(NoMergePolicy.INSTANCE));
     assertTrue(
         writer.hasUncommittedChanges()); // this will be true because a commit will create an empty
     // index
@@ -2398,22 +2398,12 @@ public class TestIndexWriter extends LuceneTestCase {
     writer.addDocument(doc);
     assertTrue(writer.hasUncommittedChanges());
 
-    // Must commit and wait for merges as long as the commit triggers merges to be certain that
-    // hasUncommittedChanges returns false
-    do {
-      writer.waitForMerges();
-      writer.commit();
-    } while (writer.hasPendingMerges());
+    writer.commit();
     assertFalse(writer.hasUncommittedChanges());
     writer.deleteDocuments(new Term("id", "xyz"));
     assertTrue(writer.hasUncommittedChanges());
 
-    // Must commit and wait for merges as long as the commit triggers merges to be certain that
-    // hasUncommittedChanges returns false
-    do {
-      writer.waitForMerges();
-      writer.commit();
-    } while (writer.hasPendingMerges());
+    writer.commit();
     assertFalse(writer.hasUncommittedChanges());
     writer.close();