fix: Move RQ metadata counter updates after successful API call#799
fix: Move RQ metadata counter updates after successful API call#799
Conversation
…ngle client In `mark_request_as_handled`, the `handled_request_count` and `pending_request_count` metadata counters were updated before the `_update_request` API call. If the API call failed, the counters would be left in an inconsistent state with no rollback. This moves the counter updates to the `else` block so they only execute after a successful API call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #799 +/- ##
==========================================
- Coverage 85.50% 85.48% -0.03%
==========================================
Files 46 46
Lines 2691 2693 +2
==========================================
+ Hits 2301 2302 +1
- Misses 390 391 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
In the case of a single RQ, I think the main source of information is local. I do not think we should wait for sucessfull API call to update metadata. The request was handled, but the API call failed. Yes, there will be inconsistency between local metadata and remote metadata, but at least the local information will be correct. Otherwise, we would have consistent, but incorrect information in both. Maybe we should introduce a retry mechanism for such failed API calls. I know they are already retried on the client level, but sometimes(very rarely) that is not enough and that leads to this inconsistency. |
I'm not sure I agree.
Correct? The API call will fail, and both will be incorrect. If I am not mistaken. @janbuchar May I ask you for your opinion? |
|
Let's use this example for discussion: RQ with 1 request. Here we discuss these two options:
Please correct me if I misunderstood the point |
Summary
handled_request_count/pending_request_countcounter updates inApifyRequestQueueSingleClient.mark_request_as_handledfrom before the API call to after a successful one.Test plan
🤖 Generated with Claude Code