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:54 UTC
(lucene) branch main 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 main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new d16e25518ba Correctly handle errors when opening DocValuesSkipper file
d16e25518ba is described below
commit d16e25518ba1a02e966875577fd90dc0573b51ed
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 c20baa4b35e..7c5f0337352 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
@@ -144,15 +144,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,
@@ -160,14 +161,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 1cf401e279f..5e4180b54ca 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -5001,7 +5001,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());