Repository navigation
Conversation
Check every item in the bulk response before acknowledging a batch. On partial or incomplete responses, retry the batch using the original document IDs. Propagate the error if retries are exhausted. Signed-off-by: 宁烁 <zhangzongning.zzn@alibaba-inc.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Poisky The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/assign @jamesgao-jpg Could you please review this PR? Thanks! |
jamesgao-jpg
left a comment
There was a problem hiding this comment.
Thanks for tracking down the silent HTTP 200 bulk partial-failure issue and adding unit tests! Checking each bulk item and retrying by document ID is the right direction; left 4 inline comments covering a split-batch count/offset bug with SerialInsertRunner, permanent-error retry amplification, offline/CI test execution, and _id-based failure diagnostics.
| self.client.bulk(body=insert_data) | ||
| response = self.client.bulk(body=insert_data) | ||
| self._validate_bulk_response(response, batch_metadata) | ||
| return (len(batch_embeddings), None) |
There was a problem hiding this comment.
[P1] Out-of-order sub-batch completion can still make SerialInsertRunner drop failed rows while reporting full inserts.
In LindormVector.insert_embeddings, inputs larger than write_vector_batch (1000) are split across concurrent sub-batches and summed in as_completed(futures) order until an error breaks the loop. With e.g. --insert-batch-size 2000 ([0:1000] and [1000:2000]), if the second sub-batch succeeds first while the first sub-batch fails item validation (returning (0, error) here), insert_embeddings returns (1000, final_error).
SerialInsertRunner.endless_insert_data then advances already_insert_count += 1000 and slices embeddings[1000:] / metadata[1000:], replaying only the already-written second sub-batch and reporting 2000 inserts even though IDs from the first sub-batch were skipped.
Could insert_embeddings return 0 retry progress on any sub-batch error ((0, final_error)) — since _id-based index operations retry idempotently — or compute a confirmed contiguous prefix from index 0, with an out-of-order regression test?
| f"Bulk insert failed: errors={response.get('errors')!r}, " | ||
| f"expected_items={len(batch_metadata)}, actual_items={len(items)}, failures={failures}" | ||
| ) | ||
| raise RuntimeError(msg) |
There was a problem hiding this comment.
[P2] Avoid 19-minute / 60-call retry cascades on permanent item errors.
Raising a plain RuntimeError for every bulk item failure causes _insert_batch_func (L237-L253) to retry 10 times (189s total backoff), and then ConcurrentInsertRunner._insert_batch_with_retry runs MAX_INSERT_RETRY = 5 additional outer retries (60 bulk calls and 1,149s total sleep) on non-transient errors such as 400 mapper_parsing_exception.
Consider raising a NonRetryableInsertError (with .non_retryable = True) for permanent 4xx / validation failures so ConcurrentInsertRunner fails fast, while preserving retries for transient failures such as 429 or 5xx.
| items = response["items"] | ||
| failures = [] | ||
| for position, doc_id in enumerate(batch_metadata): | ||
| item = items[position] if position < len(items) else None |
There was a problem hiding this comment.
[P3] Match/verify result.get("_id") when diagnosing missing or malformed items.
Matching strictly by items[position] works when responses preserve all items in order, but if an item is dropped mid-batch (e.g. submitted IDs [10, 20, 30] returning {"_id": "10"} and {"_id": "30"}), position=1 inspects _id="30" as if it were 20 and reports ID 30 as missing instead of 20. Checking result.get("_id") == str(doc_id) when _id is present keeps missing-ID diagnostics accurate.
|
|
||
| import pytest | ||
|
|
||
| from vectordb_bench.backend.clients.lindorm.lindorm_search import LindormVector |
There was a problem hiding this comment.
[P2] Allow offline test collection without opensearch-py and wire into make unittest.
Importing LindormVector unconditionally at module scope fails pytest tests/test_lindorm_bulk.py during collection (ModuleNotFoundError: No module named 'opensearchpy') in environments with only .[test] installed (including CI), and Makefile does not run this file.
Adding an ImportError stub for opensearchpy (like tests/test_clickhouse_client.py) and adding tests/test_lindorm_bulk.py to Makefile's unittest target will ensure CI executes these regression tests.
Summary
Lindorm can return HTTP 200 for a bulk request even when individual writes fail.
_insert_batch_func()currently counts the whole batch as inserted as soon asbulk()returns.We found a count discrepancy while loading the Cohere 1M dataset. VectorDBBench reported 1,000,000 inserts, but the index contained 999,794 documents after refresh. We checked the source IDs and confirmed that 206 were missing. The original run did not record per-item errors, so we couldn't determine why those particular writes failed.
Changes
Check the
errorsflag and require one successfulindexresult for each submitted document before counting the batch. If an item fails or its result is missing, the existing retry loop resends the batch with the same document IDs. A successful retry counts the batch once. If retries are exhausted, the adapter returns an error and a count of zero for that batch.Tests
Added regression tests for a partial failure followed by a successful retry, a persistent failure that exhausts retries, and a bulk response with a missing item.
pytest -q tests/test_lindorm_bulk.py— 3 passed.