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

Add retry on NoHttpResponseException #1721

Merged
merged 5 commits into from
Jul 9, 2024
Merged

Conversation

chernser
Copy link
Contributor

@chernser chernser commented Jul 6, 2024

Summary

There is a problem with keep-alive connection. Sometimes a server closes it and a client knows nothing about it. Causes of happening it are different and it is complex to resolve with a single strategy.
Apache HC throws com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.NoHttpResponseException when request is sent over a "bad" connection. This PR will retry one more time immediately if com.clickhouse.client.http.config.ClickHouseHttpOption#AHC_RETRY_ON_FAILURE is enabled.
However not every request may be retried safely. And here is another problem - it is extremely hard to detect what request is safe to retry. For example, it depends on if data stream is resettable in case of write operation.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG

@chernser chernser changed the title Add retry on NoResponse error Add retry on NoHttpResponseException Jul 6, 2024
* <li>{@code 503 Service Unavailable}</li>
* </ul>
*/
AHC_RETRY_ON_FAILURE("ahc_retry_on_failure", false, "Whether to retry on failure with AsyncHttpClient.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change the name of the property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, sure. But let me explain why I've chosen this one - implementation works only for Apache HC and only for old client.
In the new client I would name it http.retry_on_failure meaning it will be supported for every http implementation we ever have.

@chernser chernser requested a review from mzitnik July 8, 2024 20:27
@chernser chernser merged commit 03fcfb1 into main Jul 9, 2024
58 checks passed
@chernser chernser deleted the fix_stale_connection_issue branch July 9, 2024 19:35
@chernser chernser added this to the 0.6.3 Release milestone Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants