Repository navigation
Give CLI-initiated Solr connections short, shared connect/idle timeouts #4955
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b96a289
Give CLI-initiated Solr connections short, shared connect/idle timeouts
epugh 542cad3
Merge remote-tracking branch 'upstream/main' into SOLR-cli-configurab…
epugh 86f4dce
shorten up the connect timeout
epugh 17ce135
fix format
epugh 5dc0cb4
Merge branch 'main' into SOLR-cli-configurable-timeouts
jaykay12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,9 @@ | ||
| # See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc | ||
| title: bin/solr CLI commands now fail fast (3s connect / 30s idle) against an unresponsive | ||
| node instead of inheriting SolrJ's 60s/600s bulk-indexing defaults. | ||
| type: changed | ||
| authors: | ||
| - name: Eric Pugh | ||
| links: | ||
| - name: PR#4955 | ||
| url: https://github.com/apache/solr/pull/4955 |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -63,6 +63,16 @@ private CLIUtils() {} | |
| private static final long MAX_WAIT_FOR_CORE_LOAD_NANOS = | ||
| TimeUnit.NANOSECONDS.convert(1, TimeUnit.MINUTES); | ||
|
|
||
| /** | ||
| * Connect and idle timeouts used for CLI-initiated Solr connections. These are much shorter than | ||
| * {@link org.apache.solr.client.solrj.impl.SolrHttpConstants}' defaults, which are sized for | ||
| * long-running requests like bulk indexing or replica recovery; a CLI command run by a human at a | ||
| * terminal should fail fast instead of hanging for minutes against an unresponsive node. | ||
| */ | ||
| public static final int CLI_CONNECTION_TIMEOUT_SECONDS = 3; | ||
|
|
||
| public static final int CLI_IDLE_TIMEOUT_SECONDS = 30; | ||
|
|
||
| private static CloudSolrClient.CloudSolrClientConnection resolveSolrConnectionFromCli( | ||
| CommandLine cli) throws IOException { | ||
| String solrConnection = | ||
|
|
@@ -146,6 +156,8 @@ public static SolrClient getSolrClient(String solrUrl, String credentials, boole | |
| var builder = | ||
| new HttpJettySolrClient.Builder(solrUrl) | ||
| .withMaxConnectionsPerHost(32) | ||
| .withIdleTimeout(CLI_IDLE_TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||
| .withConnectionTimeout(CLI_CONNECTION_TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||
| .withKeyStoreReloadInterval(-1, TimeUnit.SECONDS) | ||
| .withOptionalBasicAuthCredentials(credentials); | ||
|
|
||
|
|
@@ -300,7 +312,11 @@ public static String solrUrlFromConnection( | |
| if (!solrConnection.isZookeeper()) { | ||
| return normalizeSolrUrl(solrConnection.quorumItems().get(0), false); | ||
| } | ||
| var builder = new HttpJettySolrClient.Builder().withOptionalBasicAuthCredentials(credentials); | ||
| var builder = | ||
| new HttpJettySolrClient.Builder() | ||
| .withIdleTimeout(CLI_IDLE_TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||
| .withConnectionTimeout(CLI_CONNECTION_TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||
| .withOptionalBasicAuthCredentials(credentials); | ||
|
Comment on lines
+316
to
+319
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any merits in extracting this HttpJettySolrClient Builder into a common class say CLIUtils & using it in all these 4 tools? would make the code duplication little lesser. |
||
| try (CloudSolrClient cloudSolrClient = getCloudSolrClient(solrConnection, builder)) { | ||
| Set<String> liveNodes = cloudSolrClient.getClusterState().getLiveNodes(); | ||
| if (liveNodes.isEmpty()) | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My local review agent was against this idea:
Here's what it quoted to me.