Ensure not to open directory reader on transport thread (#55419)

This change adds an assertion making sure that we won't accidentally
open directory readers using transport threads.
This commit is contained in:
Nhat Nguyen 2020-04-18 11:37:41 -04:00
parent a1ec45e7e6
commit 9e3b813b62
1 changed files with 3 additions and 0 deletions

View File

@ -41,6 +41,7 @@ import org.elasticsearch.index.translog.TranslogConfig;
import org.elasticsearch.index.translog.TranslogDeletionPolicy;
import org.elasticsearch.index.translog.TranslogStats;
import org.elasticsearch.search.suggest.completion.CompletionStats;
import org.elasticsearch.transport.Transports;
import java.io.Closeable;
import java.io.IOException;
@ -178,6 +179,7 @@ public class ReadOnlyEngine extends Engine {
}
protected DirectoryReader open(IndexCommit commit) throws IOException {
assert Transports.assertNotTransportThread("opening index commit of a read-only engine");
return DirectoryReader.open(commit, OFF_HEAP_READER_ATTRIBUTES);
}
@ -514,6 +516,7 @@ public class ReadOnlyEngine extends Engine {
}
protected static DirectoryReader openDirectory(Directory directory, boolean wrapSoftDeletes) throws IOException {
assert Transports.assertNotTransportThread("opening directory reader of a read-only engine");
final DirectoryReader reader = DirectoryReader.open(directory, OFF_HEAP_READER_ATTRIBUTES);
if (wrapSoftDeletes) {
return new SoftDeletesDirectoryReaderWrapper(reader, Lucene.SOFT_DELETES_FIELD);