Repository navigation
[Conductor] Add ZMQ event client with replay and reconnect - #4159
Conversation
Co-authored-by: Misak2333 <jzxscp173@163.com> Co-authored-by: Chase-Rong <lolopop.rong@gmail.com> Co-authored-by: Asher-XunZhang <asherxunzhang@gmail.com>
| if (pending_replay_ranges_.empty()) break; | ||
| range = pending_replay_ranges_.front(); | ||
| } | ||
| if (auto err = RequestReplay(range.from, range.until); |
There was a problem hiding this comment.
The vLLM ZMQ publisher already serializes live publication and replay, and replay records are emitted in monotonically increasing sequence order. The ordering issue here is in the consumer replay-timeout path.
When a gap is detected, RequestReplay() may time out, but the code then breaks out of the replay loop and immediately dispatches the current live event. A later retry can therefore apply older events after newer ones. For example, if the missing range contains Stored(A) and the live boundary is Removed(A), the removal is applied first and the replayed store can later resurrect A in the index. This does not depend on the key being evicted immediately; the missing range may span a much longer disconnect.
Could the consumer buffer subsequent live messages while replay is in progress, then dispatch the recovered range followed by the buffered messages in sequence order, with replay/live deduplication? The buffer and recovery duration should be bounded. If the missing range cannot be recovered, the affected source/index should be marked stale rather than applying older mutations after the newer boundary.
There was a problem hiding this comment.
Thanks for pointing this out. I have reworked the consumer recovery path around the following design.
1. Contiguous event application
last_seq_ now represents only the highest contiguously applied sequence.
When a gap is detected, the current live boundary is not dispatched until all preceding sequences have been recovered. A replay timeout therefore cannot cause an older mutation to be applied after a newer one.
2. Unified replay/live ordering
Live messages received beyond a gap and replayed messages are placed in the same sequence-ordered buffer.
The consumer drains the buffer only from last_seq_ + 1, ensuring cases such as Stored(A) followed by Removed(A) are always applied in the original order.
3. Replay/live deduplication
Because replay and live traffic use separate ZMQ channels, the same sequence may arrive through both paths, particularly after reconnecting.
Already-applied sequences and duplicate buffered sequences are discarded. Conflicting payloads for the same sequence cause the source to be marked stale.
4. Bounded recovery
Recovery is bounded by:
- A total recovery deadline.
- A maximum buffered-message count.
- A maximum buffered-byte count.
These limits prevent indefinite recovery and unbounded memory usage.
5. Fail-closed stale handling
If the missing range cannot be recovered, replay is unavailable, or a recovery limit is exceeded, the source is marked stale and no newer mutations are applied.
Staleness is propagated through the mandatory EventHandler::OnSourceStale(...) callback, requiring the index layer to invalidate or exclude data belonging to that source until a full resynchronization is completed.
The reconnect path uses the same ordering, buffering, and deduplication logic.
There was a problem hiding this comment.
LGTM. Thanks for the fixs.
Description
Add a reusable ZMQ client for Mooncake Conductor KV-event publishers.
The client:
EventHandlerinterface for decoded batch dispatch.Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
build:
Test results:

Checklist
./scripts/code_format.shAI Assistance Disclosure
codex was used for repository inspection.