Skip to content

Commit 2c12b8d

Browse files
committed
fix: add stability check to wait_for_vector_indexing to prevent race 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 #1412 Signed-off-by: rtmalikian <rtmalikian@gmail.com>
1 parent dffcdcb commit 2c12b8d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

weaviate/collections/batch/batch_wrapper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ def wait_for_vector_indexing(
8585
logger.debug("Waiting for async indexing to finish...")
8686
time.sleep(0.25)
8787
waiting_count += 1
88+
# Stability check: wait briefly and re-verify to prevent race condition
89+
# where shards report READY + vectorQueueSize=0 while objectCount
90+
# has not yet caught up to the inserted objects.
91+
# See: https://github.com/weaviate/weaviate-python-client/issues/1412
92+
time.sleep(0.5)
93+
if not self.__is_ready(how_many_failures, shards):
94+
return self.wait_for_vector_indexing(shards, how_many_failures)
8895
logger.debug("Async indexing finished!")
8996

9097
def __get_shards_readiness(self, shard: Shard) -> List[bool]:
@@ -186,6 +193,13 @@ async def wait_for_vector_indexing(
186193
logger.debug("Waiting for async indexing to finish...")
187194
await asyncio.sleep(0.25)
188195
waiting_count += 1
196+
# Stability check: wait briefly and re-verify to prevent race condition
197+
# where shards report READY + vectorQueueSize=0 while objectCount
198+
# has not yet caught up to the inserted objects.
199+
# See: https://github.com/weaviate/weaviate-python-client/issues/1412
200+
await asyncio.sleep(0.5)
201+
if not await self.__is_ready(how_many_failures, shards):
202+
return await self.wait_for_vector_indexing(shards, how_many_failures)
189203
logger.debug("Async indexing finished!")
190204

191205
async def __get_shards_readiness(self, shard: Shard) -> List[bool]:

0 commit comments

Comments
 (0)