Max scroll limit breach to throw a OpenSearchRejectedExecutionException (#1054)

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

Signed-off-by: Bukhtawar Khan bukhtawa@amazon.com
This commit is contained in:
Bukhtawar Khan 2021-08-10 20:32:04 +05:30 committed by GitHub
parent ca3ced981f
commit fbdc180944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -65,6 +65,7 @@ import org.opensearch.common.util.BigArrays;
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;
@ -656,7 +657,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
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.");

View File

@ -37,7 +37,6 @@ import org.apache.lucene.index.FilterDirectoryReader;
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;
@ -56,6 +55,7 @@ import org.opensearch.common.io.stream.StreamInput;
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;
@ -575,7 +575,7 @@ public class SearchServiceTests extends OpenSearchSingleNodeTestCase {
}
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(
@ -607,7 +607,7 @@ public class SearchServiceTests extends OpenSearchSingleNodeTestCase {
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 + "]. " +