Skip to content

feat(storage): add cutover-claim predicate FindNextApplyOperationCutover#398

Merged
Kiran01bm merged 2 commits into
mainfrom
kiran01bm/cutover-claim-predicate
Jun 17, 2026
Merged

feat(storage): add cutover-claim predicate FindNextApplyOperationCutover#398
Kiran01bm merged 2 commits into
mainfrom
kiran01bm/cutover-claim-predicate

Conversation

@Kiran01bm

Copy link
Copy Markdown
Collaborator

What

Adds FindNextApplyOperationCutover, the storage claim primitive for the cutover phase — the counterpart to FindNextApplyOperation (the copy gate). It atomically claims a row parked at waiting_for_cutover, transitions it to cutting_over, and rotates a fresh operation lease, using FOR UPDATE SKIP LOCKED under READ COMMITTED.

Two claim paths:

  • Start a parked cutover — gated completed-only in deployment_order: a later deployment may cut over only once every earlier sibling has reached completed. Carries the on_failure: continue exemption and the pending-stop guard, mirroring the copy gate.
  • Recover a stale in-flight cutover — a cutting_over/revert_window row whose heartbeat went stale is re-leased without changing state, with no ordering gate (the swap already started).

Why

The copy gate relaxes the deployment-order barrier once an earlier sibling reaches the cutover barrier, so copies can overlap. The cutover (the high-risk atomic swap) must not: its "done" set is completed-only so swaps run strictly one at a time, in order. This primitive is additive and dormant — nothing claims it yet — and is the first slice of ordered cutover (OC-1).

Cutover counterpart to FindNextApplyOperation: claims a row parked at
waiting_for_cutover and drives it to cutting_over only when its turn comes
in deployment order. Unlike the copy gate's barrier relaxation, the cutover
"done" set is completed-only so the atomic swaps never overlap and run
strictly in order, with the on_failure "continue" exemption and pending-stop
guard mirrored from the copy gate. A stale in-flight cutover is re-leased
without an ordering gate so a dead driver's swap can be recovered.
Copilot AI review requested due to automatic review settings June 17, 2026 03:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new MySQL storage “claim” primitive to safely advance apply_operations into the cutover phase, mirroring the existing copy-phase claim logic while enforcing stricter deployment-order semantics for cutover.

Changes:

  • Extends the ApplyOperationStore interface with FindNextApplyOperationCutover for cutover-phase claiming.
  • Implements FindNextApplyOperationCutover in the MySQL store using SELECT … FOR UPDATE SKIP LOCKED under READ COMMITTED, supporting both “start parked cutover” and “recover stale in-flight cutover” paths.
  • Adds a focused test suite that pins ordering, stop-guard behavior, on_failure “continue” exemption, and stale-recovery semantics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/storage/storage.go Adds the new storage interface method with detailed contract documentation.
pkg/storage/mysqlstore/apply_operations.go Implements the atomic cutover-claim + lease-rotation transaction and stale recovery path.
pkg/storage/mysqlstore/apply_operations_test.go Adds coverage to validate cutover ordering gates, stop behavior, on_failure exemption, and stale recovery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Kiran01bm Kiran01bm marked this pull request as ready for review June 17, 2026 04:06
@Kiran01bm Kiran01bm requested review from aparajon and morgo as code owners June 17, 2026 04:06
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Kiran01bm Kiran01bm merged commit c0bca02 into main Jun 17, 2026
29 checks passed
@Kiran01bm Kiran01bm deleted the kiran01bm/cutover-claim-predicate branch June 17, 2026 21:09
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.

3 participants