Skip to content

feat: support instance incarnation tracking and lease-lost failover.#48

Merged
JimHsiung merged 1 commit into
jd-opensource:mainfrom
JimHsiung:feat/instance_failover
Mar 24, 2026
Merged

feat: support instance incarnation tracking and lease-lost failover.#48
JimHsiung merged 1 commit into
jd-opensource:mainfrom
JimHsiung:feat/instance_failover

Conversation

@JimHsiung
Copy link
Copy Markdown
Collaborator

此次改动主要是增加 xllm-service 在“实例重启/替换”和“etcd lease 丢失”场景下的容错链路。核心思路是给实例和请求都引入 incarnation_id,把同名实例的不同世代区分开,避免旧 heartbeat、旧 delete 事件或失败清理误伤新实例上的请求。

实现上,InstanceMgr 新增了 ACTIVE -> LEASE_LOST -> SUSPECT 运行时状态机:收到 etcd delete 后不再立刻摘实例,而是先做一次 /health 探测;探测成功则进入 LEASE_LOST,实例在持续 heartbeat 的情况下仍可继续参与调度;如果后续心跳超时,再转成 SUSPECT,窗口到期后才真正注销。

同时,调度阶段会把请求绑定到具体的 prefill/decode incarnation_id,后续实例失效时按 instance + incarnation 精确清理请求;调度和负载均衡也会跳过不可调度实例。RPC 协议和 master 配置项也同步补了 incarnation_id、探测超时和 LEASE_LOST 心跳超时参数。

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

此拉取请求通过引入实例世代跟踪和租约丢失故障转移机制,显著增强了 xllm-service 的容错能力。核心改动包括在实例和请求中引入 incarnation_id,以及实现 ACTIVE -> LEASE_LOST -> SUSPECT 运行时状态机。这些改动确保了在实例重启、替换或 etcd 租约丢失场景下,系统能够准确区分不同世代的实例,避免旧事件误伤新实例上的请求。健康探测和状态协调线程的引入进一步完善了故障恢复流程。整体而言,代码质量高,逻辑清晰,并发处理得当,有效提升了服务的健壮性。

Comment thread xllm_service/scheduler/scheduler.cpp Outdated
Comment thread xllm_service/scheduler/scheduler.cpp Outdated
@JimHsiung JimHsiung force-pushed the feat/instance_failover branch from 2900f50 to e47a6c5 Compare March 23, 2026 03:47
Copy link
Copy Markdown
Collaborator

@yq33victor yq33victor left a comment

Choose a reason for hiding this comment

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

LGTM

@JimHsiung JimHsiung force-pushed the feat/instance_failover branch from e47a6c5 to 3de0c6a Compare March 24, 2026 03:10
@JimHsiung JimHsiung requested a review from RobbieLeung March 24, 2026 03:11
@JimHsiung JimHsiung merged commit 55821ad into jd-opensource:main Mar 24, 2026
1 check passed
@JimHsiung JimHsiung deleted the feat/instance_failover branch March 24, 2026 03:12
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.

4 participants