Add retry option to AsyncTAPJob.fetch_result for transient failures - #696
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #696 +/- ##
=======================================
Coverage ? 84.09%
=======================================
Files ? 80
Lines ? 8556
Branches ? 0
=======================================
Hits ? 7195
Misses ? 1361
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
177065f to
169b1c5
Compare
msdemlei
left a comment
There was a problem hiding this comment.
I'm not quite sure how a ChunkedEncodingError could be transient on a reliable channel like TCP, but I'm happy to take your word for it if you say that's been a reasoned choice.
I'd also say that a bit of randomness is a good idea in the backoff, but random.uniform(0,1) is overdoing things (which, incidentally, I'd write as random.random()). How about random.uniform(0.8, 1)?
The second enumeration of the transient exceptions (line 1078f) should also use the symbolic name.
And I wonder if the code didn't become clearer if you did without last_exception and re-raised or updated as appropriate in the exception handlers. I think in this case I'd prefer a tiny bit of repetition over a variable changed in a fairly complex pattern.
Thanks for the review @msdemlei, I've made some changes to hopefully address your comments. |
msdemlei
left a comment
There was a problem hiding this comment.
I'm happy with that improvement, thanks.
@bsipocz, would you also have a quick look and then merge if you don't find any major snags?
For the record, I am not opposed to classifying ChunkedEncodingError as temporary if it turns out that's a common failure mode; it's just that I couldn't see a probably scenario for that. So, totally feel free to add it back if you find it'd be useful.
I don't really have much opinion about ChunkedEncodingError, but the tests should pass before we can merge this. |
a228a47 to
a68aa5c
Compare
Yea sorry about that, I forgot to remove the relevant test case for this error. I've removed it now and it looks like the tests all passed. |
Problem
(Reposting from issue)
Queries via Pyvo may occasionally run into intermittent/transient networking issues during result fetching, forcing users to re-run entire queries. We've seen this during testing from our automated bots, but have not narrowed down the cause yet, and it is very likely that this is an issue specific to our setup. However I have seen these one-off behaviors with other TAP services out in the wild as well, so I'm wondering if this is something worth addressing in pyvo.
Solution
Add configurable retry logic specifically for transient network errors during result fetching. This mirrors retry patterns used in other HTTP clients.
Changes
Add max_retries parameter to fetch_result()
Implement exponential backoff with jitter
Perhaps only retry on clearly transient errors? (connection resets, timeouts)
Should be fully backwards compatible
I think something like this has the benefit of improving reliability and reducing the need for users to implement their own retry logic.
Addresses issue #695