collections/batch/sync.py: after a fast hang-up reconnect the old stream's sender steals a request, hanging add_object
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- grpc, python
- Lĩnh vực
- backend, distributed-systems
Hướng nghiên cứu
Start with weaviate/collections/batch/sync.py, especially __send around line 294 and the reconnect logic in recv_wrapper around lines 520–532. Trace how a request taken from __reqs is handled when its stream has ended, then add a regression test using a stubbed server that reconnects quickly. Done means queued objects are neither lost nor left inflight, and shutdown still ends both stream threads.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What goes wrong
During collection.batch.stream(), the server can end the gRPC stream unexpectedly ("context canceled" or "Socket closed", as when the coordinator node shuts down ungracefully). The client then reconnects and opens a new stream. If that reconnect finishes in under a second, the old stream's request sender is still running. It takes the next batch off the queue and hands it to the dead stream, where gRPC drops it. Those objects never reach the server and never show up in failed_objects, and every later add_object call hangs.
How the pieces work today:
__send(sync.py:274) is the generator gRPC reads requests from. It waits up to 1 s for a request (self.__reqs.get(timeout=1),sync.py:294). It checks the hung-up, shutting-down and out-of-memory flags, and stops, only when that wait times out (sync.py:306-315).- On a hang-up,
recv_wrapperreconnects (sync.py:524), clears the sets of unacknowledged uuids (sync.py:529-530), and starts__recvagain. The new__recvfirst clears the hung-up flag (sync.py:322-324). - gRPC's thread that reads requests for the old call stays blocked inside
__send. When it gets a request, it sees the call has ended and returns without sending it (consume_request_iteratoringrpc/_channel.py). add_objectwaits while__is_blocked(sync.py:636-643) is true. That includes when__inflight_objs, the set of sent but unacknowledged object uuids, holds__batch_sizeentries or more.
One run, with a batch size of 100:
- A stream import is running. The old
__sendis waiting inget(timeout=1). - The server hangs up.
recv_wrappersets the hung-up flag, reconnects in 300 ms, clears__inflight_objs, and starts a new__recv, which clears the hung-up flag. - The old
__send's wait has not timed out, so it never saw the flag.__loopputs the next 100 objects on the queue, and the old__sendtakes them. It adds their 100 uuids to__inflight_objs(sync.py:301-303) and yields the request into the dead call, which drops it. - The server never receives those 100 objects, so it never acknowledges them.
__inflight_objsstays at 100,__is_blockedstays true, and the nextadd_objectwaits forever.failed_objectsis empty.
When the old sender takes the None that _shutdown puts on the queue instead, the new stream never gets its stop message and its receive thread never ends. _wait's join then times out without raising.
Reachability: reachable. The trigger is a server hang-up on a multi-node cluster at a consistency level other than ALL. There, __reconnect (sync.py:468-492) calls close() and connect(force=True), with no node-health wait and no sleep when the first attempt succeeds. A single-node cluster or ConsistencyLevel.ALL first waits for every node to report healthy, polling every 5 s. A failed first attempt sleeps 1 s. Either delay lets the old get time out and see the flag, which closes the window. Not measured: how long a production close() plus connect(force=True) takes, which decides how often the window opens.
Severity: high. Up to one batch of objects is lost without appearing in failed_objects, and the import hangs.
Location: weaviate/collections/batch/sync.py:294 at origin/main 2ec127a3. The other lines cited above are at the same commit.
- https://github.com/weaviate/weaviate-python-client/blob/2ec127a3afcce49400df27d18dea3d04cea3e0d2/weaviate/collections/batch/sync.py#L293-L324
- https://github.com/weaviate/weaviate-python-client/blob/2ec127a3afcce49400df27d18dea3d04cea3e0d2/weaviate/collections/batch/sync.py#L520-L532
- https://github.com/weaviate/weaviate-python-client/blob/2ec127a3afcce49400df27d18dea3d04cea3e0d2/weaviate/collections/batch/sync.py#L636-L643
Excerpt (sync.py:293-324 at 2ec127a3, middle cut):
try:
req = self.__reqs.get(timeout=1)
if req is None:
...
yield batch_pb2.BatchStreamRequest(stop=batch_pb2.BatchStreamRequest.Stop())
return
with self.__acks_lock:
self.__inflight_objs.update(req.uuids)
self.__inflight_refs.update(req.beacons)
yield req.proto
continue
except Empty:
if self.__is_shutting_down.is_set():
...
return
elif self.__is_oom.is_set():
...
return
elif self.__is_hungup.is_set():
logger.info("Detected hung up stream, closing the client-side of the stream")
return
...
def __recv(self) -> None:
self.__is_renewing_stream.clear()
self.__is_shutting_down.clear()
self.__is_hungup.clear()
Reproduction: no committed test. A probe against a stubbed server reproduced it on two runs, with the reconnect duration stubbed as well:
- Stream 1 aborted at start, instant reconnect:
added=100 server got=0 lost=100 failed_objects=0 inflight=100. The user thread was still stuck in_add_objectafter 25 s. - Control, 2 s reconnect:
server got=500 lost=0, and both background threads end.
Provenance: pre-existing. Blame dates the cited lines to commits from January to April 2026 (ab084109, 66407ec5, 06726fe9, fbbaae8d, 6dce1053). They are still on origin/main at 2ec127a3.
Suggested fix: give each stream its own stop signal, or a generation counter, that the old __send checks after get. It then puts a taken request back, or fails it, instead of yielding it into a dead call.
Related: #2139 is about the same reconnect path but a different defect: there, __reconnect closes the connection that every thread shares.
- Ngôn ngữ chính
- Python
- Star
- 230
- Fork
- 173
- Merge trung bình
- 4 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của weaviate/weaviate-python-client
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
weaviate/weaviate-python-client#2265 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Batch: re-added rate-limited objects stay in results.objs.all_responses as errorsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
weaviate/weaviate-python-client#2179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
collections/batch: one object that fails client-side encoding fails every object sent with itCó thể đã có người làm @shadowmodder đã nhận hôm nay. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
weaviate/weaviate-python-client#2266 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
batch insert fails the whole batch with "ValueError: Unexpected type" when a value is a DecimalCó thể đã có người làm @steven-asearcy đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
weaviate/weaviate-python-client#2263 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
weaviate/weaviate-python-client#2259 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của weaviate/weaviate-python-client
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
breaking change
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
it-at-m/lhm_actions#441 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
TigreGotico/euskaphone#68 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] arc_agi_2: a correct grid in the format the prompt asks for scores 0 (exact_match gold is a one-line list)Có thể đã có người làm @BahaaMattar đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
huggingface/lighteval#1510 ·
Maintainer thường phản hồi trong vòng 1 ngày