mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #402] scheduler: store-level fencing token for in-flight Redis writes during failover #101
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#101
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @NickNYU on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/402
Affected component
Gateway / scheduler
Problem statement
The scheduler's leader gate fences request entry, not writes already in flight. When the old leader loses the Lease it force-stops, but a handler that already passed the gate (
RecordAssignment,Heartbeatreconcile) can still commit its Redis write after the new leader takes over — there is no store-level fencing token. Surfaced in the #341 review and accepted there as a documented residual; this issue tracks the proper fix.Use case
HA scheduler failover under write load: a slow heartbeat reconcile (roster diff computation) or a
RecordAssignmentretry races the old leader's process exit.Current behavior and workarounds
Accepted residual, documented in
services/README.md("In-flight writes during failover"):lease_duration > renew_deadlineinvariant already guarantees no new request is served concurrently by two replicas.RecordAssignmentis overwritten by the gateway's retry onto the new leader.The workaround bounds the damage but cannot prevent it; worst case is a routing
NotFoundfor an affected sandbox until the next heartbeat.Desired behavior
Proposed approach
LeaderTransitionsobserved at acquire), held in the leadership snapshot.Record, reconcile delete/upsert) carries the epoch; the Redis path becomes a conditional write (Lua) that applies only if the epoch is not older than the stored one.Compatibility and operational impact
API/config changes: none.
Snapshot or storage format changes: Redis binding values gain an epoch field (or a companion epoch key); old entries treated as epoch 0.
New host/runtime requirements: none.
Upgrade and rollback considerations: mixed old/new schedulers during rollout must tolerate missing epochs (treat absent as oldest).
Alternatives considered
Pre-submission checklist