Skip to content

fix(scheduler): client keep-alive stamps survive concurrent versioned writes - #39

Open
b7r6 wants to merge 2 commits into
mainfrom
fix/keepalive-versioned-writes
Open

b7r6 wants to merge 2 commits into
mainfrom
fix/keepalive-versioned-writes

Conversation

@b7r6

@b7r6 b7r6 commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

What and why

Lane A stability fix from the findings catalog (see nativelink-findings-2026-10-05.csv
on the meta/findings-catalog-2026-10-05 branch), rebased onto OSS main
@bf4b3aa855. This fork PR exists to validate the change on CI that is
representative of upstream PR lanes (public read-only cache, same endpoints)
before any upstream submission.

How was this verified?

The branch carries its own regression tests (fails-without where the fix
class allows it — see the branch's test commits). This PR's purpose is the
full representative CI run; green here rehearses the exact checks an
upstream PR would face.

Risk

Fork-internal validation PR; nothing lands anywhere by merging this. The
underlying fix's risk assessment happens at upstream-submission time.

AI assistance

Agent-assisted pipeline (Claude) for rebase and PR mechanics under my
direction; the fix itself carries verification in its tests.

@github-actions

This comment has been minimized.

@b7r6
b7r6 force-pushed the fix/keepalive-versioned-writes branch 2 times, most recently from 7afe9bd to 6cae4ea Compare October 7, 2026 20:28
b7r6 and others added 2 commits October 7, 2026 23:07
… writes

Client keep-alive stamps in the memory awaited-action db (the
ActionEvent::ClientKeepAlive path in handle_action_events, and the
initial stamp in try_subscribe) mutate the AwaitedAction in place via
send_if_modified WITHOUT bumping AwaitedActionVersion. Any concurrent
read-modify-write cycle (SimpleSchedulerStateManager borrow() ->
update_awaited_action) that snapshotted the action at version N before
the stamp still passes the version CAS, and send_replace writes the
whole stale snapshot back -- a classic lost update that silently moves
last_client_keepalive_timestamp backwards. The Code::Aborted retry
defense never fires because the version matches. Consequence: the
client-timeout sweep force-fails operations whose clients are alive and
polling ("no more clients listening" DeadlineExceeded), including
operations a client subscribed to moments earlier.

Fix shape: treat the keep-alive stamp as data outside the versioned
snapshot rather than routing it through the versioned update path.
update_awaited_action now merges the stamp forward (monotone max of old
and new) before send_replace, so an accepted stale write can never
revert it. Chosen over version-bumping keep-alives because (1) a bump
would spuriously abort legitimate in-flight worker updates and wake
every changed() subscriber ~every CLIENT_KEEPALIVE_DURATION per client,
(2) it needs no new per-operation state, and (3) it leaves the
AwaitedAction wire/record format and the store/redis backend untouched.

Two deterministic repro tests included; both fail without the one-line
merge and pass with it (verified both directions, 5x each).

Provenance: adversarial review fleet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@b7r6
b7r6 force-pushed the fix/keepalive-versioned-writes branch from 6cae4ea to c640c6b Compare October 8, 2026 17:51
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.

1 participant