fix: verify shared request queue is_finished against per-request reads - #1087
Open
vdusek wants to merge 3 commits into
Open
fix: verify shared request queue is_finished against per-request reads#1087vdusek wants to merge 3 commits into
vdusek wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1087 +/- ##
==========================================
+ Coverage 92.24% 92.33% +0.08%
==========================================
Files 51 51
Lines 3249 3260 +11
==========================================
+ Hits 2997 3010 +13
+ Misses 252 250 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vdusek
marked this pull request as ready for review
August 11, 2026 08:02
Contributor
|
Maybe the |
Pijukatel
reviewed
Aug 14, 2026
Comment on lines
+367
to
+377
| for request_id, cached_request in list(self._requests_cache.items()): | ||
| if cached_request.was_already_handled: | ||
| continue | ||
|
|
||
| request = await self._get_request_by_id(request_id) | ||
| if request is None or request.handled_at is None: | ||
| return False | ||
|
|
||
| cached_request.was_already_handled = True | ||
|
|
||
| return True |
Contributor
There was a problem hiding this comment.
Discussion points:
- In a normal scenario, are there many requests being double-checked like this, or will most of the requests already short-circuit this function due to
cached_request.was_already_handled? - Maybe it would make sense to check those requests in parallel instead of one by one?
(not to be blocked byawait self._get_request_by_id(request_id)in for loop)
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.
test_request_queue_is_finished_and_is_empty[shared]failed on master(run 31375518173)
with
assert not True.In shared access mode
is_finished()answered solely from the queue head listing, which is eventuallyconsistent: right after a committed
add_requestthe head can come back empty with no locked requests, so thequeue briefly reported itself as finished. That is a client defect, not just a test problem - a crawler polling
is_finished()in that window would shut down with work still in the queue.is_finished()now confirms an empty-head verdict before reportingTrue: every request this client knowsabout and has not yet seen handled is re-checked with a strongly consistent
get_requestread. A request thatis missing (not yet propagated) or unhandled (pending, or locked by another client) keeps the queue unfinished;
confirmed-handled requests are remembered, so each one is verified at most once. An in-flight
add_batch_of_requestscall also keeps the queue unfinished. Only the shared client changes - the singleclient already tracks added requests in its local head estimation, so it is consistent locally.
The test-side polling from the previous revision is reverted: the strict negative
is_finishedassertions areback and serve as regression coverage for the client-side guarantee.
Verified by injecting the propagation lag deterministically (first head listing after each add returns an
empty, lock-free head without hitting the API): the unfixed client reproduces the exact CI failure, the fixed
one passes 10/10 runs with strict assertions. New unit tests cover the verification paths, and the whole
integration module passes under
--numprocesses=auto.✍️ Drafted by Claude Code