Skip to content

Commit

Permalink
Max scroll limit breach to throw a OpenSearchRejectedExecutionExcepti…
Browse files Browse the repository at this point in the history
…on (#1054)

* Changes the Exception to throw a OpenSearchRejectedExecutionException on max scroll limit breach

Signed-off-by: Bukhtawar Khan bukhtawa@amazon.com
  • Loading branch information
Bukhtawar authored Aug 10, 2021
1 parent ca3ced9 commit fbdc180
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.opensearch.common.util.CollectionUtils;
import org.opensearch.common.util.concurrent.ConcurrentCollections;
import org.opensearch.common.util.concurrent.ConcurrentMapLong;
import org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException;
import org.opensearch.core.internal.io.IOUtils;
import org.opensearch.index.Index;
import org.opensearch.index.IndexNotFoundException;
Expand Down Expand Up @@ -656,7 +657,7 @@ final ReaderContext createAndPutReaderContext(ShardSearchRequest request, IndexS
if (request.scroll() != null) {
decreaseScrollContexts = openScrollContexts::decrementAndGet;
if (openScrollContexts.incrementAndGet() > maxOpenScrollContext) {
throw new OpenSearchException(
throw new OpenSearchRejectedExecutionException(
"Trying to create too many scroll contexts. Must be less than or equal to: [" +
maxOpenScrollContext + "]. " + "This limit can be set by changing the ["
+ MAX_OPEN_SCROLL_CONTEXT.getKey() + "] setting.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.store.AlreadyClosedException;
import org.opensearch.OpenSearchException;
import org.opensearch.action.ActionListener;
import org.opensearch.action.OriginalIndices;
import org.opensearch.action.index.IndexResponse;
Expand All @@ -56,6 +55,7 @@
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.index.Index;
import org.opensearch.index.IndexModule;
Expand Down Expand Up @@ -575,7 +575,7 @@ public void testMaxOpenScrollContexts() throws Exception {
}

final ShardScrollRequestTest request = new ShardScrollRequestTest(indexShard.shardId());
OpenSearchException ex = expectThrows(OpenSearchException.class,
OpenSearchRejectedExecutionException ex = expectThrows(OpenSearchRejectedExecutionException.class,
() -> service.createAndPutReaderContext(
request, indexService, indexShard, indexShard.acquireSearcherSupplier(), randomBoolean()));
assertEquals(
Expand Down Expand Up @@ -607,7 +607,7 @@ public void testOpenScrollContextsConcurrently() throws Exception {
try {
searchService.createAndPutReaderContext(
new ShardScrollRequestTest(indexShard.shardId()), indexService, indexShard, reader, true);
} catch (OpenSearchException e) {
} catch (OpenSearchRejectedExecutionException e) {
assertThat(e.getMessage(), equalTo(
"Trying to create too many scroll contexts. Must be less than or equal to: " +
"[" + maxScrollContexts + "]. " +
Expand Down

0 comments on commit fbdc180

Please sign in to comment.