test: fix flaky test_request_queue_unlock_requests#844
Open
vdusek wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
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:
|
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.
44e03e0 to
ad43eec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix this flaky CI run of
test_request_queue_unlock_requests[sync], which failed withassert 2 == 3onunlock_response.unlocked_count.Root cause: server-side replication lag.
list_and_lock_head(limit=3)acknowledges 3 locks on one replica, but the immediately followingunlock_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_conditionhelper instead of a fixed sleep. Locked requests are excluded from the queue head, so the test pollslist_headuntil none of the just-locked request IDs reappear there — i.e. all three lock writes have become visible to subsequent reads. (get_requestexposes 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
poll_until_condition/call_with_exp_backofftest helpers (shared signatures withapify-sdk-python/crawlee-python) and rebuildcollect_iterate_until_presenton top ofpoll_until_condition.poll_until_conditionto fix the flakytest_request_queue_unlock_requests.