Repository navigation
Conversation
A dry run of the stopped statement showed today's route while the apply resumes the run, and a host had no call telling resume from no stopped run. ResumesStoppedRun answers it; the plan gains resumes (format 44).
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
🤖 Review 1/2 (correctness) of 55d9872: 0 blocking, 5 non-blocking. Inspected the whole change at The change is sound for what it sets out to do. The resume condition is the apply's own ( Non-blocking
Test that passes on 55d9872 and fails when those withdrawals are deletedfunc TestResumeStoppedRunWithdrawsARefusal(t *testing.T) {
eligible := true
r := plan.NewReport(plan.SourceAlter)
r.Schema, r.Table = "app", "orders"
r.Disposition = router.DispositionRewriteRequired
r.Reason, r.Class, r.Owner = verdict.ReasonUnsupportedStatement, verdict.ClassByDesign, verdict.OwnerDirectOperator
r.Statements = []plan.Statement{{
SQL: "ALTER TABLE app.orders ALTER COLUMN qty TYPE bigint",
Route: planner.RouteRefuse,
Disposition: router.DispositionRewriteRequired,
Reason: verdict.ReasonUnsupportedStatement,
Class: verdict.ClassByDesign,
Owner: verdict.OwnerDirectOperator,
BlockingPassthroughEligible: &eligible,
RefusalCause: verdict.CauseColumnFirstForeignKey,
Guidance: suggest.GuidanceSplitStatement,
Decisions: []planner.Decision{{
Operation: "ALTER COLUMN qty TYPE bigint",
Route: planner.RouteRefuse,
SaferSQL: []string{"SELECT 1"},
}},
ExecSQL: []string{"SELECT 1"},
Execution: planner.ExecutionAutocommit,
}}
require.NoError(t, plan.ResumeStoppedRun(&r, plan.Resume{Phase: "cutover"}))
st := r.Statements[0]
assert.Equal(t, planner.RouteCopyAndSwap, st.Route)
assert.Equal(t, router.BackendCopyAndSwap, st.Backend)
assert.Equal(t, router.DispositionExecute, st.Disposition)
assert.Equal(t, router.DispositionExecute, r.Disposition)
assert.Empty(t, st.Reason)
assert.Empty(t, st.Class)
assert.Empty(t, st.Owner)
assert.Empty(t, r.Reason)
assert.Empty(t, r.Class)
assert.Empty(t, r.Owner)
assert.Nil(t, st.BlockingPassthroughEligible)
assert.Empty(t, st.RefusalCause)
assert.Empty(t, st.Guidance)
assert.Empty(t, st.ExecSQL)
assert.Empty(t, st.Execution)
assert.Nil(t, st.Decisions[0].SaferSQL)
assert.Equal(t, &plan.Resume{Phase: "cutover"}, st.Resumes)
}
func TestResumeStoppedRunRefusesAnyOtherLength(t *testing.T) {
r := plan.NewReport(plan.SourceAlter)
require.Error(t, plan.ResumeStoppedRun(&r, plan.Resume{Phase: "copying"}))
r.Statements = make([]plan.Statement, 2)
require.Error(t, plan.ResumeStoppedRun(&r, plan.Resume{Phase: "copying"}))
}Both pass on
Test that passes on 55d9872 and fails when the resume branch is removedfunc TestDryRunTextNamesTheResumeOfAStoppedRun(t *testing.T) {
r := plan.NewReport(plan.SourceAlter)
r.Schema, r.Table, r.ServerVersion = "public", "orders", "16.10"
r.Disposition = router.DispositionExecute
r.Statements = []plan.Statement{{
SQL: `ALTER TABLE "orders" ALTER COLUMN "qty" TYPE bigint`,
Route: planner.RouteNative,
Backend: router.BackendNative,
Disposition: router.DispositionExecute,
Decisions: []planner.Decision{{
Operation: "ALTER COLUMN qty TYPE bigint",
Route: planner.RouteNative,
Reason: planner.ReasonMetadataOnly,
}},
ExecSQL: []string{`ALTER TABLE "orders" ALTER COLUMN "qty" TYPE bigint`},
Execution: planner.ExecutionAutocommit,
}}
require.NoError(t, plan.ResumeStoppedRun(&r, plan.Resume{Phase: "cutover"}))
var out strings.Builder
require.NoError(t, writeDryRunTextWithCopySwapFlags(&out, palette{}, r, copySwapRunFlags{blockWrites: "public.orders"}))
flat := strings.Join(strings.Fields(out.String()), " ")
assert.Contains(t, flat, "pg-sprite will resume the copy-and-swap run of this statement stopped in phase cutover")
assert.NotContains(t, flat, "will run it as a copy-and-swap")
assert.Contains(t, out.String(), "plan:\n public.orders (PostgreSQL 16.10) — 1 statement, 1 step to run, 0 refused\n")
}
VerifiedRan, on
This review was generated by Claude Code (claude-sonnet-5-5). |
|
🤖 Review 2/2 (OSS adoption and integration) of 55d9872: 0 blocking, 2 non-blocking. Read the change from two seats: an importer that plans through Non-blocking
VerifiedRead for adoption: the doc row and history entry, the integration guide paragraph, the
This review was generated by Claude Code (claude-sonnet-5-5). |
aparajon
left a comment
There was a problem hiding this comment.
🤖 Stamping with comments: 0 blocking, 7 non-blocking (see the review comments above).
This stamp was left by Claude Code (claude-sonnet-5-5).
A dry run of a stopped copy-and-swap run's own statement now shows that the apply will resume that run, and hosts get a call that answers the same question.
Why
When a copy-and-swap run stops, rerunning the same statement resumes it from its checkpoint. The dry run did not look for the stopped run, so it showed the route the statement would take on the table as it is now, sometimes even a native one when the swap had already committed, while the apply would hand it back to copy-and-swap. A host had a call that says whether a statement is refused over a stopped run, but nothing that says it would resume.
What
migrate.ResumesStoppedRun(ctx, pool, st, schema, table, opts) (plan.Resume, bool, error), besideAdmitStoppedRunand reading the row the same read-only way without the table lock: true only when the statement is the stopped one and--restartis not set. A host calls both: refused, resumes, or routes as usual.resumes: {phase}, applied byplan.ResumeStoppedRun: route and backendcopy-and-swap, dispositionexecute, noexec_sql, refusal fields and guidance cleared; the planner's decisions keep their classification. Not in the fingerprint; the route and backend it sets are.format_version43 → 44, withplan-report.md, CLI output examples and the demo's pins.schemabot-integration.md: the sentence saying the dry run shows today's route now describes the resume and the host call.verifyingkeeps the refusal for another statement and now assertsresumes: {phase: verifying}for its own (absent under--restart), and fails when the dry run skips the read; apkg/migrateintegration test covers the three answers; a unit test pins the rewritten statement's JSON.Before / after
A write-blocking
ALTER TABLE orders ALTER COLUMN qty TYPE bigintstopped inverifying, previewed with the same statement.Another statement on the same table still previews the
copy-and-swap-run-stoppedrefusal.