Skip to content

fix(operator): unblock sweep when schema migration is timeout-skipped#64

Merged
passcod merged 1 commit into
mainfrom
operator-sweep-after-timeout-skipped
Jun 7, 2026
Merged

fix(operator): unblock sweep when schema migration is timeout-skipped#64
passcod merged 1 commit into
mainfrom
operator-sweep-after-timeout-skipped

Conversation

@passcod

@passcod passcod commented Jun 7, 2026

Copy link
Copy Markdown
Member

🤖

Summary

The post-switchover sweep — the bit that deletes the prior Active restore once the grace period has elapsed — was gated on a "migration is done" check that hadn't been updated when the `timeout-skipped` phase was added. So a replica whose last migration timed out kept treating the migration as in-flight forever, the sweep never ran, stale Active restores accumulated, and once three were live the `MAX_RESTORES_PER_REPLICA` guardrail blocked new restores too. Effect: the replica was "Ready" but functionally frozen on a stale snapshot until manual intervention.

Fix

Re-code the gate as "migration is not actively in flight" (`phase != Some("active")`) rather than enumerating every terminal phase. The set of phases has grown — `complete`, `partial`, `failed: `, now `timeout-skipped` — and the previous allow-list shape meant each new phase risked silently re-introducing this class of deadlock.

Shape

  • New `persistent_schemas_migration_settled(replica) -> bool` predicate, one definition, used by the sweep gate.
  • Sweep block calls it instead of inlining the enumeration.

Tests

Four new unit tests:

  • settled when `persistent_schemas` is unset (no migration ever runs)
  • settled when status has no phase yet
  • settled in each terminal phase (`complete`, `partial`, `timeout-skipped`, `failed: …`)
  • not settled when phase is `active`

Recovery

Existing replicas in the field with `schemaMigrationPhase: "timeout-skipped"` will recover automatically on first reconcile after deploy: the sweep runs, deletes the stale Actives, clears the phase, and the next scheduled restore can proceed. No manual cleanup required.

The post-switchover sweep deletes Active restores other than the
currentRestore once the switchover grace period has elapsed. The gate
that allows it to run was an allow-list of "migration is done" phases:
`None`, `complete`, `partial`. When the `timeout-skipped` phase was
added the gate was not updated, so a replica whose last migration
timed out kept treating the migration as in-flight forever. The sweep
never ran; stale Active restores accumulated; once three Actives
existed the MAX_RESTORES_PER_REPLICA guardrail blocked new restores
too. The replica was "Ready" but functionally frozen on a stale
snapshot until manual intervention.

Re-code the gate as "migration is not actively in flight" — i.e. not
`Some("active")` — rather than enumerating every terminal phase. The
set of phases has grown over time and adding new ones shouldn't risk
silently re-introducing this class of deadlock. Extract the predicate
as `persistent_schemas_migration_settled` so it has one definition
and can be tested directly.
@passcod passcod merged commit a5395e4 into main Jun 7, 2026
18 checks passed
@passcod passcod deleted the operator-sweep-after-timeout-skipped branch June 7, 2026 21:49
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