Skip to content

schemachange: name what a stopped run holds on every resume refusal - #640

Draft
Kiran01bm wants to merge 1 commit into
mainfrom
kiran01bm/pd118-standing-run-every-refusal
Draft

Kiran01bm wants to merge 1 commit into
mainfrom
kiran01bm/pd118-standing-run-every-refusal

Conversation

@Kiran01bm

Copy link
Copy Markdown
Collaborator

More resume refusals of a stopped copy-and-swap run now say what the run still holds, the shadow, slot or write fence, and checkpoint row, and how to clear it.

Why

A copy-and-swap run that stops keeps a shadow table, a replication slot or write fence, and a checkpoint row until it is resumed or removed, and a live run's slot keeps the server from recycling WAL the whole time. When a resume was refused because the shadow had been changed by hand or a conversion function had changed, the refusal did not say any of that was still standing, so an operator could walk away from a slot that grows the server's disk use until someone notices.

What

  • StandingRunError (the typed leftovers: shadow, slot and publication, row phase, Hold) now rides on resume-row-mismatch from a changed shadow, copy-conversion-drift (on resume and mid-run), resume-slot-held and resume-slot-backlog, as it already did on resume-source-changed and the cutover drift causes. One helper, leavesStanding, attaches it.
  • Left out on purpose: refusals where the run has ended, the swap outcome is unknown, the row is malformed or names another table, slot or shadow, the shadow is gone, or the slot belongs to someone else; none of those has a hold --restart or discard would truthfully clear.
  • The migrate verdict for these causes shares standingRefusalDetail: the refusal, the leftovers, how to resume where that is possible (undo the catalog change, wait for the holder), then --restart and pg-sprite discard <table>. resume-slot-backlog's detail is migrate: name the table and the discard in the divergence and backlog remedies #629's and is left as it is.
  • Integration tests on PG 14 and 16 assert the typed StandingRunError with Hold: replication-slot for a conversion drift and a changed shadow on a live run stopped at verifying, and for the backlog refusal from each stop phase.
  • Docs: invariants, refusal classes, SchemaBot integration.

Before / after

A live run of ALTER TABLE app.orders ALTER COLUMN amount TYPE numeric(14,2) USING in_cents(amount), stopped at verifying, then resumed after someone changed in_cents.

Before
  resume → refused: copy-conversion-drift
           error: RefusalError only, no StandingRunError
           detail: names the drift, not what stands
  left behind, unsaid: shadow _pgsprite_..._new, slot pgsprite_app_orders (retaining WAL), checkpoint row

After
  resume → refused: copy-conversion-drift
           error: RefusalError + StandingRunError{ shadow, slot, phase: verifying, Hold: replication-slot }
           detail: the drift; the shadow, slot and row still standing; restore in_cents to resume,
                   or --restart app.orders, or pg-sprite discard app.orders

A resume refused for a changed shadow, conversion drift, a held slot or
a slot backlog left the same shadow, slot or fence, and row, but only a
changed source said so, and a live run's slot kept retaining WAL.
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