Repository navigation
migrate: let the dry run decide an attach's DEFAULT write window - #652
Conversation
The dry run planned an online attach beside a DEFAULT partition as executing, so a CI gate on it passed an attach the run refuses. It now makes the attach's own catalog checks and takes --accept-default-write-window.
…bm/partitioned-attach-default-dryrun The base now carries main's online attach route; the dry run's doc keeps main's list of checks and adds the attach's catalog checks.
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 33a3e9e: 0 blocking, 3 non-blocking. Inspected the whole change at The change does what it says. The apply refuses a parent with a DEFAULT partition inside Invariants ( Non-blocking
Test case (not run here: needs a live server): the report names the table when the bound is unprovablefunc TestAttachPartitionOnlineNamesTheTableWhenTheBoundIsUnprovable(t *testing.T) {
withAttachProofServer(t, func(t *testing.T, newFixture func(t *testing.T) attachProofFixture) {
f := newFixture(t)
f.exec(t, `
CREATE TABLE %[1]s.readings (sensor integer NOT NULL) PARTITION BY RANGE (sensor);
CREATE TABLE %[1]s.readings_low (sensor integer NOT NULL)`)
rep, err := f.attachOnlineTo(t, "readings", f.pool,
`ALTER TABLE %[1]s.readings ATTACH PARTITION %[1]s.readings_low FOR VALUES FROM (0) TO ('one hundred')`,
attachFlowOptions, RunStep{})
require.ErrorIs(t, err, errAttachBoundUnprovable)
assert.Equal(t, "readings_low", rep.Table)
})
}Written against the fixture helpers in the neighbouring tests; expected to fail on
Test case (not run here: needs a live server): a dry run of an attach of a missing table ends in the run's refusalfunc TestMigrateDryRunRefusesAnAttachOfAMissingTableLikeApply(t *testing.T) {
url := testutil.StartPostgres(t)
pool, err := dbconn.NewPool(t.Context(), dbconn.Config{URL: url})
require.NoError(t, err)
t.Cleanup(pool.Close)
schema := testutil.NewSchema(t, pool)
_, err = pool.Exec(t.Context(), fmt.Sprintf(
`CREATE TABLE %[1]s.orders (id bigint NOT NULL, day date NOT NULL) PARTITION BY RANGE (day)`, schema))
require.NoError(t, err)
alter := fmt.Sprintf(`ALTER TABLE %[1]s.orders ATTACH PARTITION %[1]s.orders_2027 FOR VALUES FROM ('2027-01-01') TO ('2028-01-01')`, schema)
applied, err := runMigrate(t, newMigrateCmd(url, alter))
require.ErrorIs(t, err, verdict.ErrRefused)
dry := newMigrateCmd(url, alter)
dry.DryRun = true
planned, err := runMigrate(t, dry)
require.ErrorIs(t, err, verdict.ErrRefused)
assert.Equal(t, applied, planned)
}Modelled on the PR's own test and its helpers ( Verified
This review was generated by Claude Code (claude-sonnet-5-5). |
|
🤖 Review 2/2 (OSS adoption and integration) of 33a3e9e: 0 blocking, 3 non-blocking. Read the change from two seats: an importer that embeds the engine and builds its own dry run from the exported Non-blocking
What reads well for adopters
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, 6 non-blocking (see the review comment(s) above).
This stamp was left by Claude Code (claude-sonnet-5-5).
f6526c3
into
kiran01bm/partitioned-attach-default-window
|
🤖 Adversarial review response — created by Kiran's code review agent (Amp, Claude Opus 5.5) — pull/652, follow-up PR #652 merged into #644's branch at the reviewed head, so 5 of 6 non-blocking findings are fixed in a follow-up PR from
No action: the "Verified" section and the mutation table in C1, and "What reads well for adopters" in C2. Source: block/pg-sprite#652, review comments 7272019135 and 7272021239 and review 6108407522 at head |
migrate --dry-runnow ends an onlineATTACH PARTITIONbeside aDEFAULTpartition in the same refusal the run ends in, and takes--accept-default-write-windowto plan the accepted attach.Why
A partitioned table can have a
DEFAULTpartition that catches rows no other partition takes. Attaching a new partition online next to it briefly refuses writes that land in the new range, so pg-sprite only does it when the operator accepts that window with--accept-default-write-window. The dry run did not look at the table for this: it reported such an attach as ready to run, so a CI check on the dry run passed a change the real run then refused, and the flag could not be passed to the dry run at all.What
executor.AdmitAttachPartitionmakes the online attach's own checks, in the attach's order, up to the point where the attach would change anything: the tables resolve, the bound is provable, the table to attach is a child of nothing, and aDEFAULTpartition needs the accepted window. A table already attached is admitted, as the rerun only drops leftover proofs. The attach flow and the admission shareresolveTarget,readMembershipandrefusePrepare, so they cannot drift.migrate.AdmitOnlineAttachCatalogturns those refusals into the run's verdicts, theDEFAULTwindow into the run'sby-designrefusal;migrate.AdmitAcceptDefaultWriteWindowrejects a flag naming another table, as the run does.--accept-default-write-windowis no longer rejected with--dry-run.cli.md,limitations.md,plan-report.md,schemabot-integration.md) no longer say the dry run skips this check.Before / after
The same statement on a parent
ordersthat has aDEFAULTpartition, without the flag: the dry run used to pass it, and the run refused it. Now both refuse it. With the flag, the dry run plans the attach the accepted run executes. Nothing changes for an attach on a parent without aDEFAULTpartition.