Skip to content

fix: add stability check to wait_for_vector_indexing (Fixes #1412)#2086

Open
rtmalikian wants to merge 1 commit into
weaviate:mainfrom
rtmalikian:fix/issue-1412-wait-indexing-race
Open

fix: add stability check to wait_for_vector_indexing (Fixes #1412)#2086
rtmalikian wants to merge 1 commit into
weaviate:mainfrom
rtmalikian:fix/issue-1412-wait-indexing-race

Conversation

@rtmalikian

Copy link
Copy Markdown
Contributor

Fixes #1412

Problem

wait_for_vector_indexing() has a race condition: shards briefly report READY + vectorQueueSize=0 while objectCount has not yet caught up to the objects inserted in the batch. This causes the function to return too early, before vector indexing is actually complete.

Root Cause

The readiness check (status == "READY" AND vectorQueueSize == 0) does not verify object count. In a brief window after insertion, the shard status can satisfy both conditions while objects are still being counted.

Solution

Add a stability check after the initial readiness detection:

  1. After the while loop exits (readiness detected), wait 0.5 seconds
  2. Re-verify readiness with a second poll
  3. If the shard is no longer ready, re-enter the wait loop

This ensures the readiness state is stable before returning, preventing false-positive completion.

Changes

  • weaviate/collections/batch/batch_wrapper.py — Both sync (_BatchWrapper) and async (_BatchWrapperAsync) paths

Verification

  • Syntax check: python3 -c "import ast; ast.parse(...)" — passes
  • Ruff lint: all checks passed
  • Both sync and async code paths updated identically

Changelog

Date Change Author
2026-07-02 Add stability check to wait_for_vector_indexing (sync and async) rtmalikian

Files Changed

  • weaviate/collections/batch/batch_wrapper.py — Added 0.5s cooldown + re-verification in both sync and async wait_for_vector_indexing methods

Verification

  • ast.parse() syntax check passed
  • ruff check passed with no errors

About the Author: Raphael Malikian — Clinical AI Solutions Architect. I specialise in building and fixing AI/ML systems for healthcare, including vector databases, RAG pipelines, and clinical NLP. If you need help with your project or think I can add value to your organisation, feel free to reach out — I'd love to connect.

📧 rtmalikian@gmail.com
🔗 GitHub: https://github.com/rtmalikian
🔗 LinkedIn: http://www.linkedin.com/in/raphael-t-malikian-mbbs-bsc-hons-71075436a

…condition

Shards briefly report READY + vectorQueueSize=0 while objectCount
has not yet caught up to the inserted objects. This causes
wait_for_vector_indexing() to return too early.

Fix: After detecting readiness, wait 0.5s and re-verify.
If the shard is no longer ready, continue waiting.

Fixes weaviate#1412

Signed-off-by: rtmalikian <rtmalikian@gmail.com>

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

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.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

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.

Wait for async indexing function returning too early

2 participants