Repository navigation
fix(batch): stop a stale stream sender from stealing requests after a fast reconnect - #2262
Open
shadowmodder wants to merge 2 commits into
Open
shadowmodder wants to merge 2 commits into
shadowmodder wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
|
To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge. |
Contributor
Author
|
I agree with the CLA |
This branch has not been deployed
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.
Fixes #2261
What changes
After a hang-up,
recv_wrapperreconnects and starts a new stream. If the reconnect finishes within the old sender's 1s queue wait, the old__sendgenerator — still blocked in__reqs.get()— wakes with the next request, adds its uuids to__inflight_objs, and yields it into the dead call, where gRPC drops it. The batch is lost silently and, with__inflight_objswedged at the batch size, every lateradd_objecthangs. The same steal applies to theNonestop sentinel, which the live stream then never receives.__recvnow bumps a stream generation counter on every new stream and passes it to__send.get,__sendchecks that its generation is still current (and that the stream has not hung up). A stale sender returns the request to the queue for the live stream's sender and exits, without touching__inflight_objs.weaviate/collections/batch/async_.py) is fixed the same way.Testing
mock_tests/test_batch.pydrive the race deterministically without a server: a stale sync sender returning a data request, a stale sync sender returning the stop sentinel, and the async variant. Each asserts the request is handed back,__inflight_objsstays empty, and the live sender then delivers the request exactly once.mock_tests/test_batch.py: the 3 new tests pass. The 5 pre-existing mock-server tests error at fixture setup in my sandbox both before and after this change (local gRPC mock port), so no regression is attributable to this change; CI will exercise them.