* Changes the Exception to throw a OpenSearchRejectedExecutionException on max scroll limit breach Signed-off-by: Bukhtawar Khan bukhtawa@amazon.com Co-authored-by: Bukhtawar Khan <bukhtawa@amazon.com>
This commit is contained in:
parent
6fe24609e0
commit
f52755857d
|
@ -65,6 +65,7 @@ import org.opensearch.common.util.BigArrays;
|
||||||
import org.opensearch.common.util.CollectionUtils;
|
import org.opensearch.common.util.CollectionUtils;
|
||||||
import org.opensearch.common.util.concurrent.ConcurrentCollections;
|
import org.opensearch.common.util.concurrent.ConcurrentCollections;
|
||||||
import org.opensearch.common.util.concurrent.ConcurrentMapLong;
|
import org.opensearch.common.util.concurrent.ConcurrentMapLong;
|
||||||
|
import org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException;
|
||||||
import org.opensearch.core.internal.io.IOUtils;
|
import org.opensearch.core.internal.io.IOUtils;
|
||||||
import org.opensearch.index.Index;
|
import org.opensearch.index.Index;
|
||||||
import org.opensearch.index.IndexNotFoundException;
|
import org.opensearch.index.IndexNotFoundException;
|
||||||
|
@ -656,7 +657,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
|
||||||
if (request.scroll() != null) {
|
if (request.scroll() != null) {
|
||||||
decreaseScrollContexts = openScrollContexts::decrementAndGet;
|
decreaseScrollContexts = openScrollContexts::decrementAndGet;
|
||||||
if (openScrollContexts.incrementAndGet() > maxOpenScrollContext) {
|
if (openScrollContexts.incrementAndGet() > maxOpenScrollContext) {
|
||||||
throw new OpenSearchException(
|
throw new OpenSearchRejectedExecutionException(
|
||||||
"Trying to create too many scroll contexts. Must be less than or equal to: [" +
|
"Trying to create too many scroll contexts. Must be less than or equal to: [" +
|
||||||
maxOpenScrollContext + "]. " + "This limit can be set by changing the ["
|
maxOpenScrollContext + "]. " + "This limit can be set by changing the ["
|
||||||
+ MAX_OPEN_SCROLL_CONTEXT.getKey() + "] setting.");
|
+ MAX_OPEN_SCROLL_CONTEXT.getKey() + "] setting.");
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.apache.lucene.index.FilterDirectoryReader;
|
||||||
import org.apache.lucene.index.LeafReader;
|
import org.apache.lucene.index.LeafReader;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.apache.lucene.store.AlreadyClosedException;
|
import org.apache.lucene.store.AlreadyClosedException;
|
||||||
import org.opensearch.OpenSearchException;
|
|
||||||
import org.opensearch.action.ActionListener;
|
import org.opensearch.action.ActionListener;
|
||||||
import org.opensearch.action.OriginalIndices;
|
import org.opensearch.action.OriginalIndices;
|
||||||
import org.opensearch.action.index.IndexResponse;
|
import org.opensearch.action.index.IndexResponse;
|
||||||
|
@ -56,6 +55,7 @@ import org.opensearch.common.io.stream.StreamInput;
|
||||||
import org.opensearch.common.io.stream.StreamOutput;
|
import org.opensearch.common.io.stream.StreamOutput;
|
||||||
import org.opensearch.common.settings.Settings;
|
import org.opensearch.common.settings.Settings;
|
||||||
import org.opensearch.common.unit.TimeValue;
|
import org.opensearch.common.unit.TimeValue;
|
||||||
|
import org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException;
|
||||||
import org.opensearch.common.xcontent.XContentBuilder;
|
import org.opensearch.common.xcontent.XContentBuilder;
|
||||||
import org.opensearch.index.Index;
|
import org.opensearch.index.Index;
|
||||||
import org.opensearch.index.IndexModule;
|
import org.opensearch.index.IndexModule;
|
||||||
|
@ -574,7 +574,7 @@ public class SearchServiceTests extends OpenSearchSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
final ShardScrollRequestTest request = new ShardScrollRequestTest(indexShard.shardId());
|
final ShardScrollRequestTest request = new ShardScrollRequestTest(indexShard.shardId());
|
||||||
OpenSearchException ex = expectThrows(OpenSearchException.class,
|
OpenSearchRejectedExecutionException ex = expectThrows(OpenSearchRejectedExecutionException.class,
|
||||||
() -> service.createAndPutReaderContext(
|
() -> service.createAndPutReaderContext(
|
||||||
request, indexService, indexShard, indexShard.acquireSearcherSupplier(), randomBoolean()));
|
request, indexService, indexShard, indexShard.acquireSearcherSupplier(), randomBoolean()));
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -606,7 +606,7 @@ public class SearchServiceTests extends OpenSearchSingleNodeTestCase {
|
||||||
try {
|
try {
|
||||||
searchService.createAndPutReaderContext(
|
searchService.createAndPutReaderContext(
|
||||||
new ShardScrollRequestTest(indexShard.shardId()), indexService, indexShard, reader, true);
|
new ShardScrollRequestTest(indexShard.shardId()), indexService, indexShard, reader, true);
|
||||||
} catch (OpenSearchException e) {
|
} catch (OpenSearchRejectedExecutionException e) {
|
||||||
assertThat(e.getMessage(), equalTo(
|
assertThat(e.getMessage(), equalTo(
|
||||||
"Trying to create too many scroll contexts. Must be less than or equal to: " +
|
"Trying to create too many scroll contexts. Must be less than or equal to: " +
|
||||||
"[" + maxScrollContexts + "]. " +
|
"[" + maxScrollContexts + "]. " +
|
||||||
|
|
Loading…
Reference in New Issue