Skip to content

Commit 5ca112b

Browse files
authored
Fix flaky testOverflowDisabledAsynchronous by throwing AlreadyClosedException (#20848)
When the file cache is full and a blob fetch races with cache eviction, DelayedCreationCachedIndexInput.getIndexInput() throws an IllegalStateException, so this surfaces as an IllegalStateException instead of the IOException callers expect. Replace IllegalStateException with Lucene's AlreadyClosedException (which extends IOException) in both getIndexInput() and asyncLoadIndexInput(). Signed-off-by: Andrew Ross <andrross@amazon.com>
1 parent 0e2783c commit 5ca112b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/main/java/org/opensearch/index/store/remote/utils/TransferManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.apache.logging.log4j.LogManager;
1212
import org.apache.logging.log4j.Logger;
13+
import org.apache.lucene.store.AlreadyClosedException;
1314
import org.apache.lucene.store.IOContext;
1415
import org.apache.lucene.store.IndexInput;
1516
import org.opensearch.common.annotation.ExperimentalApi;
@@ -206,7 +207,7 @@ private DelayedCreationCachedIndexInput(FileCache fileCache, StreamReader stream
206207
@Override
207208
public IndexInput getIndexInput() throws IOException {
208209
if (isClosed.get()) {
209-
throw new IllegalStateException("Already closed");
210+
throw new AlreadyClosedException("Already closed");
210211
}
211212
if (isStarted.getAndSet(true) == false) {
212213
// We're the first one here, need to download the block
@@ -233,7 +234,7 @@ public IndexInput getIndexInput() throws IOException {
233234
public CompletableFuture<IndexInput> asyncLoadIndexInput(Executor executor) {
234235
if (isClosed.get()) {
235236
fileCache.decRef(request.getFilePath());
236-
return CompletableFuture.failedFuture(new IllegalStateException("Already closed"));
237+
return CompletableFuture.failedFuture(new AlreadyClosedException("Already closed"));
237238
}
238239
if (isStarted.getAndSet(true) == false) {
239240
// Create new future and set it as the result

0 commit comments

Comments
 (0)