mirror of https://github.com/apache/lucene.git
Close all files when hitting an I/O exception with vectors. (#12807)
This was found by `testRandomExceptions()`: if an exception occurs when opening the meta file, then the `rawVectorsReader` that is passed to the constructor never gets closed.
This commit is contained in:
parent
a13a4224d8
commit
5afc17d4b5
|
@ -92,18 +92,8 @@ public final class Lucene99HnswVectorsReader extends KnnVectorsReader
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
priorE = exception;
|
priorE = exception;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
CodecUtil.checkFooter(meta, priorE);
|
||||||
CodecUtil.checkFooter(meta, priorE);
|
|
||||||
success = true;
|
|
||||||
} finally {
|
|
||||||
if (success == false) {
|
|
||||||
IOUtils.close(flatVectorsReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
success = false;
|
|
||||||
try {
|
|
||||||
vectorIndex =
|
vectorIndex =
|
||||||
openDataInput(
|
openDataInput(
|
||||||
state,
|
state,
|
||||||
|
|
|
@ -58,6 +58,7 @@ public final class Lucene99ScalarQuantizedVectorsReader extends FlatVectorsReade
|
||||||
|
|
||||||
Lucene99ScalarQuantizedVectorsReader(SegmentReadState state, FlatVectorsReader rawVectorsReader)
|
Lucene99ScalarQuantizedVectorsReader(SegmentReadState state, FlatVectorsReader rawVectorsReader)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
this.rawVectorsReader = rawVectorsReader;
|
||||||
int versionMeta = -1;
|
int versionMeta = -1;
|
||||||
String metaFileName =
|
String metaFileName =
|
||||||
IndexFileNames.segmentFileName(
|
IndexFileNames.segmentFileName(
|
||||||
|
@ -80,19 +81,8 @@ public final class Lucene99ScalarQuantizedVectorsReader extends FlatVectorsReade
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
priorE = exception;
|
priorE = exception;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
CodecUtil.checkFooter(meta, priorE);
|
||||||
CodecUtil.checkFooter(meta, priorE);
|
|
||||||
success = true;
|
|
||||||
} finally {
|
|
||||||
if (success == false) {
|
|
||||||
IOUtils.close(rawVectorsReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
success = false;
|
|
||||||
this.rawVectorsReader = rawVectorsReader;
|
|
||||||
try {
|
|
||||||
quantizedVectorData =
|
quantizedVectorData =
|
||||||
openDataInput(
|
openDataInput(
|
||||||
state,
|
state,
|
||||||
|
|
Loading…
Reference in New Issue