Skip to content

Harmonize SolrJ timeouts #3357

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

dsmiley
Copy link
Contributor

@dsmiley dsmiley commented May 19, 2025

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOCOMMIT here; it remains to be seen how we'll solve the incompatibility of withHttpClient + with timeouts.

responseListener.get(client.getIdleTimeout(), TimeUnit.MILLISECONDS);
responseListener.get(client.getRequestTimeoutMillis(), TimeUnit.MILLISECONDS);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was weird to be using the idle (aka socket) timeout in a situation where we're waiting for the request.

@@ -129,6 +126,12 @@ protected Http2SolrClient(String serverBaseUrl, Builder builder) {
super(serverBaseUrl, builder);

if (builder.httpClient != null) {
if (builder.followRedirects != null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOCOMMIT; it remains to be seen if we're going to retain HttpClient reuse but reusing it means we can't be customizing timeouts.

@@ -261,8 +266,6 @@ private HttpClient createHttpClient(Builder builder) {
this.authenticationStore = new AuthenticationStoreHolder();
httpClient.setAuthenticationStore(this.authenticationStore);

httpClient.setConnectTimeout(builder.connectionTimeoutMillis);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just reorganized this upwards

Comment on lines +258 to +259
httpClient.setConnectTimeout(builder.getConnectionTimeoutMillis());
httpClient.setIdleTimeout(builder.getIdleTimeoutMillis());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: these getters now resolve a default value, a primitive; do not return null.

Comment on lines -94 to +99
HttpClient.Builder b = HttpClient.newBuilder().followRedirects(followRedirects);
b.followRedirects(followRedirects);

b.connectTimeout(Duration.of(builder.getConnectionTimeoutMillis(), ChronoUnit.MILLIS));
// note: idle timeout isn't used for the JDK client
// note: request timeout is set per request
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • organizational change
  • setting the connection timeout (was forgotten!)

Comment on lines -422 to +428
if (requestTimeoutMillis > 0) {
reqb.timeout(Duration.of(requestTimeoutMillis, ChronoUnit.MILLIS));
} else if (idleTimeoutMillis > 0) {
reqb.timeout(Duration.of(idleTimeoutMillis, ChronoUnit.MILLIS));
}
reqb.timeout(Duration.of(requestTimeoutMillis, ChronoUnit.MILLIS));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as for Http2SolrClient: we now keep this simply and do defaulting logic in one common place earlier

Comment on lines -556 to -561
if (idleTimeoutMillis == null || idleTimeoutMillis <= 0) {
idleTimeoutMillis = (long) HttpClientUtil.DEFAULT_SO_TIMEOUT;
}
if (connectionTimeoutMillis == null) {
connectionTimeoutMillis = (long) HttpClientUtil.DEFAULT_CONNECT_TIMEOUT;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as for Http2SolrClient: these settings were redundant/duplicative and thus misleading. Only need to be inside the underlying HttpClient.

@@ -57,8 +57,6 @@ public abstract class HttpSolrClientBase extends SolrClient {
/** The URL of the Solr server. */
protected final String serverBaseUrl;

protected final long idleTimeoutMillis;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant with HttpClient; removed here.

Comment on lines -666 to -667
.withHttpClient(oldClient)
.withIdleTimeout(3000, TimeUnit.MILLISECONDS)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't do this pairing anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant