Skip to content

HttpSolrClient: improve error when text/html#4526

Open
dsmiley wants to merge 2 commits into
apache:mainfrom
dsmiley:HttpSolrClient_429
Open

HttpSolrClient: improve error when text/html#4526
dsmiley wants to merge 2 commits into
apache:mainfrom
dsmiley:HttpSolrClient_429

Conversation

@dsmiley

@dsmiley dsmiley commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

If most non-200 codes happen, and the Content-Type is text/html, we would throw an error relating to the content type being unexpected. We now don't mention the content type, and we simply throw a simpler exception.

Not sure if worth a JIRA but I'll add a changelog

If most non-200 codes happen, and the Content-Type is text/html, we would throw an error relating to the content type being unexpected.
We now don't mention the content type, and we simply throw a simpler exception.
import org.mockito.Mockito;

@LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17810")
//@LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17810")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will remove

return new CloudJettySolrClient.Builder(
new ZkClientClusterStateProvider(cluster.getZkServer().getZkAddress()))
.withDefaultCollection(collection)
.withHttpClientBuilder(new HttpJettySolrClient.Builder().useHttp1_1(true))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Claude's root cause, and suggested this fix:

When 350 concurrent queries hit the rate limiter and get rejected as 429s, the server sends rapid RST_STREAM frames on the multiplexed HTTP/2 connection. This triggers HTTP/2's ENHANCE_YOUR_CALM protection, which tears down the entire connection. Subsequent requests then fail with IOException, which the CloudSolrClient sees as a communication error → "No live SolrServers."

The old Apache HTTP client used HTTP/1.1 (separate connections per request), so this never happened. The Jetty client defaults to HTTP/2.

}
}

checkContentType(processor, is, mimeType, encoding, httpStatus, urlExceptionMessage);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved this above wantStream / InputStreamResponseParser because I think it makes sense to check this fairly early. Someone could subclass ISRP and specify the content types that should be checked.

Comment on lines -212 to +213
if (processor == null || mimeType == null) {
if (mimeType == null || mimeType.equals("text/html")) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the meat of the change.

Comment on lines -243 to +248
StringBuilder msg =
new StringBuilder()
.append(responseReason)
.append("\n")
.append("request: ")
.append(responseMethod);
String reason = URLDecoder.decode(msg.toString(), FALLBACK_CHARSET);
throw new RemoteSolrException(urlExceptionMessage, httpStatus, reason, null);
throw new RemoteSolrException(
urlExceptionMessage,
httpStatus,
"non ok status: " + httpStatus + ", message:" + responseReason,
null);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@HoustonPutman , you added this in SOLR-17998 #1657 I didn't see much sense in this particular string so I changed it to match the message string above line 217

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