Repository navigation
fix(batch): report a per-object encoding failure instead of failing the whole batch - #2267
Open
shadowmodder wants to merge 4 commits into
Open
shadowmodder wants to merge 4 commits into
shadowmodder wants to merge 4 commits into
Conversation
Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
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.
closes #2266
Problem
One object that fails client-side encoding fails every object batched with it, and the error does not say which object it was:
_BatchGRPC.grpc_objectsbuilt the protobuf message for the whole batch in one list comprehension, so one bad object aborted the request before anything was sent, and__send_batchattached that one error to all 100 objects.batch.stream(),__generate_stream_requestsencoded each object inside the background send loop with no per-object catch, so the error killed the loop and every unsent object was silently dropped with an emptyfailed_objects.On current main a
Decimalproperty value reaches the same failure in both modes (the ragged multi-vector trigger arrives with #2039).Fix
Encode objects one by one and record a failure as that object's own
ErrorObject:grpc_batch.py: a new_BatchGRPC.__encode_objectshelper encodes per object and collects an error message (naming the object's UUID and the underlying error) keyed by the object's position.objects()sends only the encodable objects; the response callback translates the server's error indices — which are keyed by position within the request — back to the caller's positions past any dropped object, and merges them with the encoding errors. If every object fails, it raisesWeaviateInsertManyAllFailedErroras before (without sending an empty request).grpc_objectsitself is unchanged.sync.py/async_.py:__generate_stream_requestscatches a per-object encoding exception, records it via a new__record_encoding_error(anErrorObjectkeyed byobj.indexin the results and infailed_objects; the object is removed from the uuid cache/lookup so references to it are not sent), and continues with the remaining objects.Out of scope, as noted in the issue: the stream context manager's
__exit__not re-raising the loop's exception is a separate defect. The error message carries the UUID and the underlying error; it does not thread the failing vector's name through, because encoding failures also arise from properties, where no vector name exists.Validation
Repro (offline, stub connection / white-box stream generation,
Decimalproperty as the unencodable object on main):objects()raisedValueError: Unexpected type— the whole batch of 100 was lost, the server received nothing.uuids99,errors1 (the bad object's index, message naming its UUID).Tests (5 new deterministic, server-free regression tests in
mock_tests/test_batch.py):test_grpc_objects_one_unencodable_object_does_not_fail_the_batchtest_grpc_objects_server_error_is_translated_past_an_encoding_failuretest_grpc_objects_all_unencodable_raises_all_failedtest_sync_stream_skips_unencodable_object_and_records_errortest_async_stream_skips_unencodable_object_and_records_errorAll 5 fail with the fix reverted and pass with it.
test/collection/test_batch.py: 16 passed.ruff checkandruff formatclean on the changed files. The mock-server-backed tests inmock_tests/test_batch.pycould not run in my sandbox (their gRPC mock fixture fails at setup identically on unpatched main); CI will exercise them.AI assistance was used during the creation of this PR.