Skip to content

Count failed bulk-index batches once in the reported weight - #151

Merged
janhoy merged 1 commit into
apache:mainfrom
syahra712:fix-bulk-index-weight
Nov 7, 2026
Merged

janhoy merged 1 commit into
apache:mainfrom
syahra712:fix-bulk-index-weight

Conversation

@syahra712

Copy link
Copy Markdown
Contributor

Description

SolrBulkIndex reports the wrong weight when a batch fails.

total_docs was only increased after sc.add succeeded, and then weight = total_docs - errors subtracted the failed documents a second time. For example, with bulk-size: 1 and two documents where the second batch fails:

before after
weight 0 1
bulk-size 1 2
error-count 1 1

If every batch fails, weight was negative (-N). The executor uses weight as the sample's total_ops (execute_single in worker_coordinator.py), so this went straight into indexing throughput.

The fix counts every document sent in total_docs, before the try. weight = total_docs - errors then gives the number of documents Solr accepted, which is what the existing code meant, and bulk-size is the size of the request. Nothing changes when no batch fails.

Issues Resolved

None filed. I found it while reading the runner.

Testing

  • New functionality includes testing

Two new tests in tests/unit/solr/test_runner.py:

  • test_partial_failure_counts_failed_docs_once: one batch succeeds and one fails, giving weight 1, bulk-size 2 and error-count 1.
  • test_failed_bulk_has_zero_weight: every batch fails, giving weight 0, where it used to be -1.

Both fail on main and pass with the fix. The full tests/ suite passes locally on Python 3.13 (1177 passed, 5 skipped), and so does ruff check ..


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

total_docs only counted batches that Solr accepted, and the weight
then subtracted the failed documents again. A bulk with one failed
batch out of two reported 0 docs, and a fully failed bulk reported a
negative count, which fed straight into indexing throughput.
total_docs now counts every document sent, so bulk-size is the
request size and weight is the number of documents indexed.
@janhoy
janhoy merged commit dc3f356 into apache:main Nov 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants