Skip to content

fix: commit request queue dedup cache only after batch_add_requests succeeds#975

Draft
vdusek wants to merge 3 commits into
masterfrom
fix/rq-cache-commit-on-success
Draft

fix: commit request queue dedup cache only after batch_add_requests succeeds#975
vdusek wants to merge 3 commits into
masterfrom
fix/rq-cache-commit-on-success

Conversation

@vdusek

@vdusek vdusek commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Both Apify request queue clients (ApifyRequestQueueSingleClient, ApifyRequestQueueSharedClient) inserted new requests into their local _requests_cache (and the single client's _head_requests) before calling batch_add_requests. When that API call failed, the poisoned cache entries caused a subsequent user retry of the same request to be deduplicated locally and never re-sent to the platform — silent request loss.

The cache/head commit now happens after batch_add_requests succeeds, committing only the requests the platform actually accepted (entries in unprocessed_requests are skipped). The previous "remove unprocessed from cache" cleanup loops are absorbed into this skip, since those ids are simply never added now.

Crawlee already deduplicates a batch by unique_key (via _transform_requests) before it reaches these clients, so deferring the local cache write does not lose meaningful within-batch deduplication.

Added a parametrized regression test covering both clients: a failed batch_add_requests leaves no cached entry, and the retry reaches the platform.

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jun 12, 2026
@vdusek vdusek self-assigned this Jun 12, 2026
@github-actions github-actions Bot added this to the 142nd sprint - Tooling team milestone Jun 12, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.98%. Comparing base (0daca28) to head (710ecbe).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #975      +/-   ##
==========================================
+ Coverage   89.90%   89.98%   +0.07%     
==========================================
  Files          49       49              
  Lines        3091     3105      +14     
==========================================
+ Hits         2779     2794      +15     
+ Misses        312      311       -1     
Flag Coverage Δ
e2e 35.78% <6.25%> (-0.13%) ⬇️
integration 56.74% <31.25%> (-0.13%) ⬇️
unit 81.09% <100.00%> (+2.35%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

vdusek added 2 commits June 12, 2026 18:27
…-on-success

# Conflicts:
#	tests/unit/storage_clients/test_apify_request_queue_client.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants