-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase concurrent request of opening point-in-time (#96959)
* Increase concurrent request of opening point-in-time (#96782) (#96957) Today, we mistakenly throttle the opening point-in-time API to 1 request per node. As a result, when attempting to open a point-in-time across large clusters, it can take a significant amount of time and eventually fails due to relocated target shards or deleted target indices managed by ILM. Ideally, we should batch the requests per node and eliminate this throttle completely. However, this requires all clusters to be on the latest version. This PR increases the number of concurrent requests from 1 to 5, which is the default of search. * Fix tests * Fix tests
- Loading branch information
Showing
8 changed files
with
163 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 96782 | ||
summary: Increase concurrent request of opening point-in-time | ||
area: Search | ||
type: bug | ||
issues: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
server/src/test/java/org/elasticsearch/action/search/RestOpenPointInTimeActionTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.search; | ||
|
||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections; | ||
import org.elasticsearch.rest.RestRequest; | ||
import org.elasticsearch.test.rest.FakeRestRequest; | ||
import org.elasticsearch.test.rest.RestActionTestCase; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Queue; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
|
||
public class RestOpenPointInTimeActionTests extends RestActionTestCase { | ||
|
||
public void testMaxConcurrentSearchRequests() { | ||
RestOpenPointInTimeAction action = new RestOpenPointInTimeAction(); | ||
controller().registerHandler(action); | ||
Queue<OpenPointInTimeRequest> transportRequests = ConcurrentCollections.newQueue(); | ||
verifyingClient.setExecuteVerifier(((actionType, transportRequest) -> { | ||
assertThat(transportRequest, instanceOf(OpenPointInTimeRequest.class)); | ||
transportRequests.add((OpenPointInTimeRequest) transportRequest); | ||
return new OpenPointInTimeResponse("n/a"); | ||
})); | ||
{ | ||
Map<String, String> params = new HashMap<>(); | ||
params.put("keep_alive", "1m"); | ||
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.POST) | ||
.withPath("/_pit") | ||
.withParams(params) | ||
.build(); | ||
dispatchRequest(request); | ||
assertThat(transportRequests, hasSize(1)); | ||
OpenPointInTimeRequest transportRequest = transportRequests.remove(); | ||
assertThat(transportRequest.maxConcurrentShardRequests(), equalTo(5)); | ||
} | ||
{ | ||
int maxConcurrentRequests = randomIntBetween(1, 100); | ||
Map<String, String> params = new HashMap<>(); | ||
params.put("max_concurrent_shard_requests", Integer.toString(maxConcurrentRequests)); | ||
params.put("keep_alive", "1m"); | ||
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.POST) | ||
.withPath("/_pit") | ||
.withParams(params) | ||
.build(); | ||
dispatchRequest(request); | ||
assertThat(transportRequests, hasSize(1)); | ||
OpenPointInTimeRequest transportRequest = transportRequests.remove(); | ||
assertThat(transportRequest.maxConcurrentShardRequests(), equalTo(maxConcurrentRequests)); | ||
} | ||
} | ||
} |