You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2026/04/22 14:59:58 UTC

(lucene) branch branch_10x updated: Correctly handle errors when opening DocValuesSkipper file

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

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


The following commit(s) were added to refs/heads/branch_10x by this push:
     new 7908df2b7c4 Correctly handle errors when opening DocValuesSkipper file
7908df2b7c4 is described below

commit 7908df2b7c47e8c25df8494eb2e8bd2a58a76ffa
Author: Alan Woodward <ro...@apache.org>
AuthorDate: Wed Apr 22 15:53:24 2026 +0100

    Correctly handle errors when opening DocValuesSkipper file
    
    Interruptions when opening the skipper file could cause the data file
    to leak, because the open call was outside the relevant try-catch
    block.  This caused occasional failures in TestIndexWriter concurrency
    tests.
---
 .../codecs/lucene90/Lucene90DocValuesProducer.java  | 21 +++++++++++----------
 .../org/apache/lucene/index/TestIndexWriter.java    |  1 -
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java
index 131f430f6b4..56920157e05 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java
@@ -148,15 +148,16 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
     }
 
     if (version >= Lucene90DocValuesFormat.VERSION_SKIPPER_SEPARATE_FILE) {
-      String skipIndexName =
-          IndexFileNames.segmentFileName(
-              state.segmentInfo.name, state.segmentSuffix, skipIndexExtension);
-      this.skipIndexData =
-          state.directory.openInput(skipIndexName, state.context.withHints(FileTypeHint.INDEX));
+      IndexInput skipIn = null;
       try {
+        String skipIndexName =
+            IndexFileNames.segmentFileName(
+                state.segmentInfo.name, state.segmentSuffix, skipIndexExtension);
+        skipIn =
+            state.directory.openInput(skipIndexName, state.context.withHints(FileTypeHint.INDEX));
         final int skipVersion =
             CodecUtil.checkIndexHeader(
-                skipIndexData,
+                skipIn,
                 skipIndexCodec,
                 Lucene90DocValuesFormat.VERSION_SKIPPER_SEPARATE_FILE,
                 Lucene90DocValuesFormat.VERSION_CURRENT,
@@ -164,14 +165,14 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
                 state.segmentSuffix);
         if (version != skipVersion) {
           throw new CorruptIndexException(
-              "Format versions mismatch: meta=" + version + ", skipIndex=" + skipVersion,
-              skipIndexData);
+              "Format versions mismatch: meta=" + version + ", skipIndex=" + skipVersion, skipIn);
         }
-        CodecUtil.retrieveChecksum(skipIndexData);
+        CodecUtil.retrieveChecksum(skipIn);
       } catch (Throwable t) {
-        IOUtils.closeWhileSuppressingExceptions(t, data, skipIndexData);
+        IOUtils.closeWhileSuppressingExceptions(t, data, skipIn);
         throw t;
       }
+      this.skipIndexData = skipIn;
     } else {
       this.skipIndexData = null;
     }
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 2949eec12a7..8500fdac628 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -5012,7 +5012,6 @@ public class TestIndexWriter extends LuceneTestCase {
         doc2.add(new SortedNumericDocValuesField("test", random().nextLong()));
         IllegalArgumentException ex =
             expectThrows(IllegalArgumentException.class, () -> writer.addDocument(doc2));
-        ex.printStackTrace();
         assertEquals(
             "Inconsistency of field data structures across documents for field [test] of doc [1]. doc values skip index type: expected 'RANGE', but it has 'NONE'.",
             ex.getMessage());