fix(operator): gate stop-reconciliation claims on lease staleness - #907
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the operator stop-reconciliation claim logic to be once-per-stop-request (instead of once-per-poll) by gating reclaims on lease freshness vs. control-request recency and lease heartbeat staleness, preventing a wedged stop reconciliation from monopolizing driver ticks and starving other claim rungs.
Changes:
- Gate
FindNextApplyForStopReconciliationto only match a pending stop request when the apply is unclaimed, the stop request is newer than the lease, or the lease heartbeat is stale. - Ensure
recoverApplyPendingStopdoes not consume the driver tick when the claim itself errors, allowing the claim ladder to proceed. - Add focused storage + operator tests covering lease-gated reclaim, stop re-issue behavior, and non-consuming claim errors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/storage/mysqlstore/applies.go | Adds lease/updated_at gating to stop-reconciliation claiming to prevent once-per-poll reclaims. |
| pkg/storage/mysqlstore/applies_test.go | Adds coverage for lease-staleness reclaim, stop re-issue reclaim, and queue fairness under fresh leases. |
| pkg/api/operator.go | Changes stop-reconciliation claim errors to fall through (do not consume the tick) to avoid starving later claim rungs. |
| pkg/api/operator_test.go | Adds a unit test verifying claim errors don’t consume the driver tick. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aparajon
marked this pull request as ready for review
August 5, 2026 02:21
aparajon
requested review from
JashLal,
Kiran01bm,
eeSeeGee,
jayjanssen,
jemiahw and
morgo
as code owners
August 5, 2026 02:21
aparajon
force-pushed
the
armand/stop-reconciliation-lease-gate
branch
from
August 5, 2026 16:31
962c313 to
47d15b4
Compare
The stop-reconciliation claim runs at the head of every driver tick, and claiming an apply consumes the tick before the operation claim runs. An apply whose reconciliation keeps failing after the claim (for example a data-plane stop that errors every drive) would re-match on every poll, so one wedged stop request could starve the driver ladder for every other apply. Two changes make the claim once-per-request instead of once-per-poll: - FindNextApplyForStopReconciliation only matches a pending stop when the apply has never been claimed, the stop request is newer than the lease (a re-issued stop re-opens the request and stamps its updated_at), or the prior claim's heartbeat has gone stale (a crashed or wedged driver). The claim itself rotates the lease, so a fresh lease means a driver already owns this request's reconciliation. - recoverApplyPendingStop no longer consumes the tick when the claim itself errors: a failed claim did no work and holds no lease, so the tick falls through to the operation claim instead of a persistent storage error on the first rung starving every claim behind it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
aparajon
force-pushed
the
armand/stop-reconciliation-lease-gate
branch
from
August 5, 2026 16:35
47d15b4 to
6288c12
Compare
morgo
approved these changes
Aug 5, 2026
morgo
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
When an operator tells SchemaBot to stop an apply, the stop is recorded durably and a background driver later picks it up to actually halt the work. Drivers check for pending stops first on every poll, before any other work, so a stop never waits behind new schema changes.
The problem: that check matched any apply with a pending stop — including one a driver had just picked up. If a stop kept failing to reconcile (say, halting the work errors on every attempt), every driver re-grabbed the same apply on every poll, and each grab used up the whole poll. One stuck stop could monopolize every driver in the fleet, and the actual schema-change work behind it never ran.
What it does
A stop is now handled by one driver at a time instead of every driver on every poll. Picking it up takes a lease on the apply; while that lease is fresh, every other poll skips the apply and moves on to real work.
Two details make this safe:
🤖 Generated with Claude Code