feat(cli): redrive failed schema changes#577
Open
aparajon wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an operator-facing “redrive” control path that re-plans a recently failed apply and, when the plan still matches the remaining failed work, reopens the apply by moving failed tasks/operations back to retryable states under lock ownership.
Changes:
- Introduces
schemabot redrive <apply-id>CLI + client call and a newPOST /api/redriveendpoint/response type. - Implements redrive planning/validation in the API service, including lock acquisition (and
--forcetakeover semantics) plus plan equivalence gating. - Adds storage support to transition a terminal failed apply back to
failed_retryable, preserving completed work and guarding against concurrent active applies; includes new unit tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/storage/storage.go | Adds redrive freshness constant and ApplyStore.RedriveFailed API. |
| pkg/storage/mysqlstore/applies.go | Implements RedriveFailed transition logic + active-apply checks. |
| pkg/storage/mysqlstore/applies_test.go | Adds MySQL store tests covering redrive happy-path and rejection cases. |
| pkg/storage/errors.go | Adds ErrApplyNotRedrivable. |
| pkg/cmd/main.go | Wires redrive into the CLI root command. |
| pkg/cmd/commands/redrive.go | Implements CLI redrive command behavior and output. |
| pkg/cmd/commands/common.go | Adds accepted/error wrapper for redrive responses. |
| pkg/cmd/client/client.go | Adds CallRedriveAPI and refactors control request helper for custom payloads. |
| pkg/apitypes/apitypes.go | Extends ControlRequest with force and adds RedriveResponse. |
| pkg/api/service.go | Registers /api/redrive route/handler. |
| pkg/api/redrive_handlers.go | Implements redrive handler + plan filtering/fingerprinting/equivalence check. |
| pkg/api/redrive_handlers_test.go | Adds unit tests for redrive plan matching, lock behavior, and filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d496dd2 to
1fb10db
Compare
Amp-Thread-ID: https://ampcode.com/threads/T-019ef4e0-c517-71c8-aae9-54a8f2173a85 Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019ef4e0-c517-71c8-aae9-54a8f2173a85
1fb10db to
fb9741c
Compare
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
Failed schema changes currently become terminal once their retry budget is exhausted, even when only part of the original work failed and the desired schema is still unchanged. A CLI-only redrive path lets an operator deliberately retry that same failed work without creating a replacement apply or replaying completed work.
What
schemabot redrive <apply-id>as a guarded recovery command for terminal failed applies--forcematching existing lock takeover semanticsRisk Assessment
Medium — this adds a new operator control path that can move terminal failed applies back to active retryable states. The path is CLI-only, guarded by lock ownership, freshness limits, active-apply checks, and exact re-plan matching before storage state changes.
Generated with Amp