You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2022/09/08 17:55:33 UTC

[lucene] branch branch_9x updated: Fix TestIndexWriterOnDiskFull.testAddDocumentOnDiskFull to handle IllegalStateException from startCommit() (#11757)

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

rmuir 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 b0c51236878 Fix TestIndexWriterOnDiskFull.testAddDocumentOnDiskFull to handle IllegalStateException from startCommit() (#11757)
b0c51236878 is described below

commit b0c5123687892ba97318e7349be1595b569a1d9a
Author: Robert Muir <rm...@apache.org>
AuthorDate: Thu Sep 8 13:35:54 2022 -0400

    Fix TestIndexWriterOnDiskFull.testAddDocumentOnDiskFull to handle IllegalStateException from startCommit() (#11757)
    
    If ConcurrentMergeScheduler is used, and the merge hits fatal exception (such as disk full) after prepareCommit()'s ensureOpen() check, then startCommit() will throw IllegalStateException instead of AlreadyClosedException.
    
    The test is currently not prepared to handle this: the logic is only geared around exceptions coming from addDocument()
    
    Closes #11755
---
 .../apache/lucene/index/TestIndexWriterOnDiskFull.java   | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
index 19d3284b11d..78f59300e32 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
@@ -77,8 +77,20 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
           if (VERBOSE) {
             System.out.println("TEST: done adding docs; now commit");
           }
-          writer.commit();
-          indexExists = true;
+          try {
+            // when calling commit(), if the writer is asynchronously closed
+            // by a fatal tragedy (e.g. from disk-full-on-merge with CMS),
+            // then we may receive either AlreadyClosedException OR IllegalStateException,
+            // depending on when it happens.
+            writer.commit();
+            indexExists = true;
+          } catch (IOException | IllegalStateException e) {
+            if (VERBOSE) {
+              System.out.println("TEST: exception on commit");
+              e.printStackTrace(System.out);
+            }
+            hitError = true;
+          }
         } catch (IOException e) {
           if (VERBOSE) {
             System.out.println("TEST: exception on addDoc");