[BUG] Do not queue a curl session closed by the Retry-After cap - #4632
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4632 +/- ##
==========================================
+ Coverage 86.53% 86.64% +0.12%
==========================================
Files 525 525
Lines 20482 20482
==========================================
+ Hits 17722 17745 +23
+ Misses 2760 2737 -23
🚀 New features to boost your workflow:
|
|
|
||
| started_at = std::chrono::steady_clock::now(); | ||
| http_client.WaitBackgroundThreadExit(); | ||
| const auto joined_in = std::chrono::steady_clock::now() - started_at; |
There was a problem hiding this comment.
Non-blocking: could we add a separate case that calls WaitBackgroundThreadExit() immediately after the capped request finishes, without sending the second request?
Here, the original bug spends the 30 seconds waiting for the second request to retry, so the later join can still return promptly. The retry assertion catches the bug, but a separate case would directly cover the shutdown scenario from #4631.
There was a problem hiding this comment.
Added RetryAfterBeyondMaxBackoffDoesNotDelayShutdown which calls WaitBackgroundThreadExit() right after the capped request, fails after about 30 s against the pre-fix IO loop, and passes with this fix.
lalitb
left a comment
There was a problem hiding this comment.
LGTM, thanks for the quick fix!
Fixes #4631
Changes
When a retryable response carries a Retry-After beyond max_backoff,
PerformCurlMessage() closes the session with Cleanup(). The IO loop then
asked IsRetryable() again, still got true, and queued the closed session
at the server's retry time. doRetrySessions() stops at the first entry
that is not due, so that entry held back every later retry on the client
and kept the background thread alive. WaitBackgroundThreadExit() and
~HttpClient() could not join until the server's time, and the loop
busy-spun meanwhile.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes