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) {
|
||||
priorE = exception;
|
||||
} finally {
|
||||
try {
|
||||
CodecUtil.checkFooter(meta, priorE);
|
||||
success = true;
|
||||
} finally {
|
||||
if (success == false) {
|
||||
IOUtils.close(flatVectorsReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
success = false;
|
||||
try {
|
||||
vectorIndex =
|
||||
openDataInput(
|
||||
state,
|
||||
|
|
|
@ -58,6 +58,7 @@ public final class Lucene99ScalarQuantizedVectorsReader extends FlatVectorsReade
|
|||
|
||||
Lucene99ScalarQuantizedVectorsReader(SegmentReadState state, FlatVectorsReader rawVectorsReader)
|
||||
throws IOException {
|
||||
this.rawVectorsReader = rawVectorsReader;
|
||||
int versionMeta = -1;
|
||||
String metaFileName =
|
||||
IndexFileNames.segmentFileName(
|
||||
|
@ -80,19 +81,8 @@ public final class Lucene99ScalarQuantizedVectorsReader extends FlatVectorsReade
|
|||
} catch (Throwable exception) {
|
||||
priorE = exception;
|
||||
} finally {
|
||||
try {
|
||||
CodecUtil.checkFooter(meta, priorE);
|
||||
success = true;
|
||||
} finally {
|
||||
if (success == false) {
|
||||
IOUtils.close(rawVectorsReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
success = false;
|
||||
this.rawVectorsReader = rawVectorsReader;
|
||||
try {
|
||||
quantizedVectorData =
|
||||
openDataInput(
|
||||
state,
|
||||
|
|
Loading…
Reference in New Issue