Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Jetty HTTP2 #2276

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c2e578e
SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Je…
iamsanjay Feb 18, 2024
d5bc8c4
Merge main
iamsanjay Feb 20, 2024
3572dec
SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Je…
iamsanjay Feb 20, 2024
9588fdf
Merge main
iamsanjay Feb 27, 2024
0655f11
Using FutureTask to send PREPRECOVERY, without executor
iamsanjay Feb 27, 2024
e7c346f
Merge main
iamsanjay Feb 29, 2024
0611782
Null check for FutureTask, removed try-catch
iamsanjay Feb 29, 2024
91f3c9d
code format, added test case
iamsanjay Mar 1, 2024
6a0b54b
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 3, 2024
1c6798b
Remove comment, create method for cancel recovery
iamsanjay Mar 3, 2024
5a62766
Merge main
iamsanjay Mar 7, 2024
ae368b5
Update IndexFetcher Class to Use Http2SolrClient
iamsanjay Mar 7, 2024
9e9b5f7
Adding header for compression to SolrRequests
iamsanjay Mar 7, 2024
8deebcd
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 12, 2024
625a364
Enable testing resplication handler for externalCompression
iamsanjay Mar 12, 2024
901ef51
Renaming method to more appropriate name
iamsanjay Mar 12, 2024
d574b42
Merge main
iamsanjay Mar 13, 2024
cc4011b
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 13, 2024
26a4c0e
Resolve conflicts Http2SolrClient
iamsanjay Mar 13, 2024
de5a40c
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 18, 2024
43dda16
Restoring the old auth of IndexFetcher
iamsanjay Mar 18, 2024
b48c0b9
Merge main
iamsanjay Mar 27, 2024
851109f
Fix retry fetch() IndexFetcher
iamsanjay Mar 27, 2024
6af3d76
Merge main
iamsanjay Mar 30, 2024
73c5ba8
Avoid closing InputStream before receiving zero-length Data field
iamsanjay Mar 30, 2024
4c16404
Read till end-of-file
iamsanjay Mar 30, 2024
19ec489
read till end-of-file
iamsanjay Mar 30, 2024
917509f
Merge main
iamsanjay Apr 18, 2024
c54cd5b
Added Test case for User managed replication with basic auth enabled
iamsanjay Apr 18, 2024
bb1c3b3
Removed isContentDownloaded and updated listener factory setting mech…
iamsanjay Apr 22, 2024
38f532a
Merge main
iamsanjay Apr 22, 2024
377eaa3
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Apr 30, 2024
1b9b7fc
Change return code when downloaded successfully
iamsanjay Apr 30, 2024
fdb1d1f
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay May 8, 2024
ef92b6b
tidy code
iamsanjay May 8, 2024
6279656
Update basic-authentication-plugin.adoc (#2446)
gspgsp May 8, 2024
b789a71
group operators together (#2450)
epugh May 8, 2024
f39e8ba
SOLR-17192: Add "field-limiting" URP to catch ill-designed schemas (#…
gerlowskija May 8, 2024
6bde352
CHANGES.txt
dsmiley May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ Improvements

* SOLR-17145: The INSTALLSHARDDATA API now includes a 'requestid' field when run asynchronously (Jason Gerlowski)

* SOLR-17159: bin/solr post now has proper unit testing. Users can specify a --dry-run option to
simulate posting documents without sending them to Solr. (Eric Pugh)

* SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Jetty HTTP2

Optimizations
Expand Down
10 changes: 1 addition & 9 deletions solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
import org.apache.solr.common.cloud.ZooKeeperException;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SolrNamedThreadFactory;
import org.apache.solr.common.util.URLUtil;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
Expand Down Expand Up @@ -178,7 +176,6 @@ public final void setRecoveringAfterStartup(boolean recoveringAfterStartup) {
this.recoveringAfterStartup = recoveringAfterStartup;
}

/** Builds a new HttpSolrClient for use in recovery. Caller must close */
private Http2SolrClient.Builder recoverySolrClientBuilder(String baseUrl, String leaderCoreName) {
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
// workaround for SOLR-13605: get the configured timeouts & set them directly
// (even though getRecoveryOnlyHttpClient() already has them set)
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -915,15 +912,11 @@ private final void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreNa
int readTimeout =
conflictWaitMs
+ Integer.parseInt(System.getProperty("prepRecoveryReadTimeoutExtraWait", "8000"));
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
var recoveryExec =
ExecutorUtil.newMDCAwareFixedThreadPool(
1, new SolrNamedThreadFactory("sendPrepRecoveryCmd"));
try (Http2SolrClient client =
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
recoverySolrClientBuilder(
leaderBaseUrl,
null) // leader core omitted since client only used for 'admin' request
.withIdleTimeout(readTimeout, TimeUnit.MILLISECONDS)
.withExecutor(recoveryExec)
.build()) {
log.info("Sending prep recovery command to [{}]; [{}]", leaderBaseUrl, prepCmd);
MDC.put("HttpSolrClient.url", baseUrl);
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -935,7 +928,7 @@ private final void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreNa
@Override
public void onSuccess(NamedList<Object> entries) {
log.info(
"Prep recovery command successfully send to [{}]; [{}]",
"Prep recovery command successfully sent to [{}]; [{}]",
leaderBaseUrl,
prepCmd);
}
Expand All @@ -946,7 +939,6 @@ public void onFailure(Throwable throwable) {
}
});
} finally {
recoveryExec.shutdown();
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
MDC.remove("HttpSolrClient.url");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class UpdateShardHandler implements SolrInfoBean {

private final Http2SolrClient updateOnlyClient;

// private final CloseableHttpClient recoveryOnlyClient;
private final Http2SolrClient recoveryOnlyClient;

private final CloseableHttpClient defaultClient;
Expand All @@ -86,9 +85,7 @@ public class UpdateShardHandler implements SolrInfoBean {

private final InstrumentedHttpRequestExecutor httpRequestExecutor;

private final InstrumentedHttpListenerFactory updateHttpListenerFactory;

private final InstrumentedHttpListenerFactory recoverHttpListenerFactory;
private final InstrumentedHttpListenerFactory trackHttpSolrMetrics;

private SolrMetricsContext solrMetricsContext;

Expand Down Expand Up @@ -123,8 +120,7 @@ public UpdateShardHandler(UpdateShardHandlerConfig cfg) {
log.debug("Created default UpdateShardHandler HTTP client with params: {}", clientParams);

httpRequestExecutor = new InstrumentedHttpRequestExecutor(getMetricNameStrategy(cfg));
updateHttpListenerFactory = new InstrumentedHttpListenerFactory(getNameStrategy(cfg));
recoverHttpListenerFactory = new InstrumentedHttpListenerFactory(getNameStrategy(cfg));
trackHttpSolrMetrics = new InstrumentedHttpListenerFactory(getNameStrategy(cfg));

defaultClient =
HttpClientUtil.createClient(
Expand All @@ -149,10 +145,10 @@ public UpdateShardHandler(UpdateShardHandlerConfig cfg) {

updateOnlyClientBuilder.withTheseParamNamesInTheUrl(urlParamNames);
updateOnlyClient = updateOnlyClientBuilder.build();
updateOnlyClient.addListenerFactory(updateHttpListenerFactory);
updateOnlyClient.addListenerFactory(trackHttpSolrMetrics);

recoveryOnlyClient = recoveryOnlyClientBuilder.build();
recoveryOnlyClient.addListenerFactory(recoverHttpListenerFactory);
recoveryOnlyClient.addListenerFactory(trackHttpSolrMetrics);

ThreadFactory recoveryThreadFactory = new SolrNamedThreadFactory("recoveryExecutor");
if (cfg != null && cfg.getMaxRecoveryThreads() > 0) {
Expand Down Expand Up @@ -216,7 +212,7 @@ public String getName() {
public void initializeMetrics(SolrMetricsContext parentContext, String scope) {
solrMetricsContext = parentContext.getChildContext(this);
String expandedScope = SolrMetricManager.mkName(scope, getCategory().name());
updateHttpListenerFactory.initializeMetrics(solrMetricsContext, expandedScope);
trackHttpSolrMetrics.initializeMetrics(solrMetricsContext, expandedScope);
defaultConnectionManager.initializeMetrics(solrMetricsContext, expandedScope);
updateExecutor =
MetricUtils.instrumentedExecutorService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.solr.cloud;

import com.carrotsearch.randomizedtesting.annotations.Nightly;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CountDownLatch;
Expand All @@ -36,6 +37,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

@Nightly
public class RecoveryStrategyStressTest extends SolrCloudTestCase {
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved

@BeforeClass
Expand All @@ -50,12 +52,10 @@ public void stressTestRecovery() throws Exception {
.process(cluster.getSolrClient());
waitForState(
"Expected a collection with one shard and two replicas", collection, clusterShape(1, 4));

SolrClient solrClient =
cluster.basicSolrClientBuilder().withDefaultCollection(collection).build();
final var scheduledExecutorService =
Executors.newScheduledThreadPool(1, new SolrNamedThreadFactory("stressTestRecovery"));
try (solrClient) {
try (SolrClient solrClient =
cluster.basicSolrClientBuilder().withDefaultCollection(collection).build()) {
final StoppableIndexingThread indexThread =
new StoppableIndexingThread(null, solrClient, "1", true, 10, 1, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ protected Http2SolrClient(String serverBaseUrl, Builder builder) {

this.idleTimeoutMillis = builder.idleTimeoutMillis;

executor = builder.executor;
if (executor == null) {
BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(256, 256);
this.executor =
new ExecutorUtil.MDCAwareThreadPoolExecutor(
32, 256, 60, TimeUnit.SECONDS, queue, new SolrNamedThreadFactory("h2sc"));
shutdownExecutor = true;
} else {
shutdownExecutor = false;
}
if (builder.httpClient != null) {
this.httpClient = builder.httpClient;
this.closeClient = false;
Expand Down Expand Up @@ -226,17 +236,6 @@ ProtocolHandlers getProtocolHandlers() {
private HttpClient createHttpClient(Builder builder) {
HttpClient httpClient;

executor = builder.executor;
if (executor == null) {
BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(256, 256);
this.executor =
new ExecutorUtil.MDCAwareThreadPoolExecutor(
32, 256, 60, TimeUnit.SECONDS, queue, new SolrNamedThreadFactory("h2sc"));
shutdownExecutor = true;
} else {
shutdownExecutor = false;
}

SslContextFactory.Client sslContextFactory;
if (builder.sslConfig == null) {
sslContextFactory = getDefaultSslContextFactory();
Expand Down Expand Up @@ -1162,6 +1161,10 @@ private static CookieStore getDefaultCookieStore() {
*/
public Builder withHttpClient(Http2SolrClient http2SolrClient) {
this.httpClient = http2SolrClient.httpClient;

if (this.executor == null) {
this.executor = http2SolrClient.executor;
}
if (this.basicAuthAuthorizationStr == null) {
this.basicAuthAuthorizationStr = http2SolrClient.basicAuthAuthorizationStr;
}
Expand Down
Loading