Skip to content

test: fix flaky test_request_queue_unlock_requests#844

Open
vdusek wants to merge 2 commits into
masterfrom
test/fix-flaky-unlock-requests
Open

test: fix flaky test_request_queue_unlock_requests#844
vdusek wants to merge 2 commits into
masterfrom
test/fix-flaky-unlock-requests

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Jun 2, 2026

Summary

Fix this flaky CI run of test_request_queue_unlock_requests[sync], which failed with assert 2 == 3 on unlock_response.unlocked_count.

Root cause: server-side replication lag. list_and_lock_head(limit=3) acknowledges 3 locks on one replica, but the immediately following unlock_requests() reads a replica where only 2 of the 3 lock writes had propagated, so it reports unlocking 2. The [async] variant passed in the same run — only [sync] lost the race, which is characteristic of a flake rather than a regression.

Fix: wait for the locks to propagate before unlocking, using a poll_until_condition helper instead of a fixed sleep. Locked requests are excluded from the queue head, so the test polls list_head until none of the just-locked request IDs reappear there — i.e. all three lock writes have become visible to subsequent reads. (get_request exposes no lock field, so it can't be used as the signal.)

This is a follow-up to #786, which removed the earlier cross-iteration locking ambiguity; this addresses the remaining lock→unlock replication race.

Commits

  1. Add the poll_until_condition / call_with_exp_backoff test helpers (shared signatures with apify-sdk-python / crawlee-python) and rebuild collect_iterate_until_present on top of poll_until_condition.
  2. Use poll_until_condition to fix the flaky test_request_queue_unlock_requests.

@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 2, 2026
@vdusek vdusek self-assigned this Jun 2, 2026
@github-actions github-actions Bot added this to the 142nd sprint - Tooling team milestone Jun 2, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Jun 2, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.74%. Comparing base (beab127) to head (ad43eec).

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #844       +/-   ##
===========================================
+ Coverage   83.52%   94.74%   +11.21%     
===========================================
  Files          48       48               
  Lines        5045     5045               
===========================================
+ Hits         4214     4780      +566     
+ Misses        831      265      -566     
Flag Coverage Δ
integration 93.14% <ø> (?)
unit 83.52% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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 vdusek changed the base branch from master to test/unify-polling-helpers June 2, 2026 13:44
vdusek added 2 commits June 2, 2026 15:53
Add generic `call_with_exp_backoff` and `poll_until_condition` test helpers (accepting
sync or async callables) for waiting on eventually-consistent state, and rebuild
`collect_iterate_until_present` on top of `poll_until_condition`.
Wait for the locks to propagate before unlocking, polling list_head via
poll_until_condition until the locked requests drop out of the queue head,
rather than unlocking immediately after list_and_lock_head returns.
@vdusek vdusek changed the base branch from test/unify-polling-helpers to master June 2, 2026 13:53
@vdusek vdusek force-pushed the test/fix-flaky-unlock-requests branch from 44e03e0 to ad43eec Compare June 2, 2026 13:53
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