Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

test: Fix intermittent failures with ReqwestClient #262

Merged
merged 3 commits into from
Dec 7, 2021
Merged

Conversation

ncloudioj
Copy link
Contributor

This fixes #259.

The issue was caused by the connection pool in Reqwest/Hyper. See more details in here.

Since ReqwestClient is only used by RS suggester, and it is not making constant network calls to RS. Disabling the connection pool should not be a big deal, but I will let @mythmon @Dexterp37 decide if this is acceptable or shall we keep it as is and add the retry to the API.

@ncloudioj ncloudioj requested a review from a team as a code owner December 7, 2021 03:41
@@ -20,10 +20,13 @@ pub struct ReqwestClient {

impl ReqwestClient {
/// Instantiate a new Reqwest client to perform HTTP requests.
pub fn new() -> ReqwestClient {
Self {
reqwest_client: reqwest::Client::new(),
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 noticed that request::Client::new() could panic in certain cases, but the builders let you capture those errors without panicking.

let reqwest_client = reqwest::Client::builder()
// Disable the connection pool to avoid the IncompleteMessage errors.
// See #259 for more details.
.pool_max_idle_per_host(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering why this wasn't happening with the other implementation: we were not setting the max idle per host there as well. Any idea?

Aside from that, I don't think there's a big problem in disabling pooling.

Copy link
Contributor

@mythmon mythmon left a comment

Choose a reason for hiding this comment

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

I think a better thing to do would be to change the time that reqwest keeps connections around so it doesn't outlive the Kinto connections, but I can't find what that value would be. After that, I think adding retry is going to be an important long term solution for many parts of Merino. Neither of these are quick though.

This unblocks us now, and is simple enough to understand. Lets file an issue to come back to this, and merge this fix.

@pjenvey
Copy link
Member

pjenvey commented Dec 7, 2021

I'll note that hyper v0.14.3 has a fix around connection reuse + flushing but it definitely does not help, I tried it as a long shot here

@ncloudioj ncloudioj merged commit 9d1f881 into main Dec 7, 2021
@ncloudioj ncloudioj deleted the gh-259 branch December 7, 2021 19:08
mythmon added a commit that referenced this pull request Dec 8, 2021
* Revert "Merge pull request #232 from Dexterp37/rs-client" - Integrate
  remote-settings-client
* Revert "Merge pull request #260 from mozilla-services/kinto-url-with-v1" -
  Include `/v1` on the end of the remote settings URL we give to the RS client
* Revert "Merge pull request #261 from mozilla-services/feat/259"
  don't hide inner errors in the log message
* Revert "Merge pull request #262 from mozilla-services/gh-259"
  Fix intermittent failures with ReqwestClient
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent test failure with ReqwestClient
4 participants