Skip to content

Keep pending coverage across a late degrade - #360

Closed
Amogh-Bharadwaj wants to merge 3 commits into
mainfrom
pending-degrade-cut
Closed

Amogh-Bharadwaj wants to merge 3 commits into
mainfrom
pending-degrade-cut

Conversation

@Amogh-Bharadwaj

@Amogh-Bharadwaj Amogh-Bharadwaj commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #359.

A late degrade threw away a transaction's whole pending timeline, so walshadow could stop on rows it could have decoded. In production, a migration added a column, backfilled it and set it NOT NULL. The runner then put a temp-table migration in the same transaction, and its first temp table inserted pg_temp_N after SET NOT NULL. That boundary hit capture_all, which discarded the exact slot captured right after ADD COLUMN. The commit shape then had to read the whole dirty interval, and the backfill rows were fenced (StashAmbiguous). #359's compat change avoids that specific shape. This PR fixes the underlying degrade behaviour, which still fences any physically unproven in-place change followed by a late degrade (for example varchar→text, INSERT, then the first temp table).

Changes:

  • PendingCatalog records the boundary where the timeline degraded (degraded_at). Slots before it keep answering, and the earliest position wins across subtransactions.
  • in_place_verdict fences the head run before the first slot against the predecessor, as before. It fences the tail past the cut against the last recorded shape. In the production transaction the last slot equalled the commit shape, so nothing would have fenced.
  • The drain no longer decodes records past the cut under the last slot, which could predate a shape change nothing recorded (a silent wrong-decode path). They use the commit-time descriptor.
  • Every degrade path logs a WARN with xid, boundary and reason; before, only overlay read failures did. Ambiguity WARNs now list the published spans and the degrade boundary.

Tests:

  • Unit tests for the degrade cut, subtransaction merging, head/tail spans and the drain cut.
  • e2e late_capture_all_keeps_the_earlier_timeline (isolates this fix) and backfill_then_set_not_null_with_late_temp_table_delivers (the production shape). The e2e tests type-check on Linux but have only run in CI, not locally.

Known gap, not addressed: pending slots don't survive a restart, so a re-read dirty transaction decodes under the commit-time descriptor and relies on the saved ambiguity windows.

🤖 Generated with Claude Code


Note

Medium Risk
Touches core pending-catalog, ambiguity fencing, and WAL row decode semantics; behavior change is substantial but heavily tested.

Overview
Late degrades no longer wipe an in-flight transaction’s pending catalog timeline. The catalog now records degraded_at at the boundary that caused the cut; slots captured before that boundary stay usable, with the earliest cut winning across subtransactions. PendingSlot gains captured_at so ordering and cuts follow where shapes were read, not only valid_from.

Commit capture and decoding follow the partial timeline. PromotedXact exposes Coverage (from / until / last shape) instead of treating any degrade as total loss. in_place_verdict fences the pre-slot head against the predecessor and, when needed, the post-cut tail against the last recorded shape. commit_entries lands the commit descriptor at the cut when a promoted slot would otherwise keep answering past it. The drain stores pending_until and decodes records at or after the cut under the commit-time descriptor, not the last pre-cut slot.

Operational visibility: every degrade path logs a WARN with xid, boundary, and reason; ambiguity warnings include published spans and degraded_at. New unit and e2e tests cover late capture_all, backfill + SET NOT NULL + temp table, and shape changes after a degrade.

Reviewed by Cursor Bugbot for commit f1fcc11. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/source/catalog_capture.rs Resolved
@harshil-goel
harshil-goel force-pushed the pending-degrade-cut branch 4 times, most recently from de0911e to 1b37dbc Compare November 26, 2026 13:23

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/source/catalog_capture.rs Resolved
Base automatically changed from fix-add-column-not-null to main November 26, 2026 14:13
@harshil-goel harshil-goel reopened this Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

AI review gate — AI review passed

Clean review from: Cursor Bugbot.

Amogh-Bharadwaj and others added 2 commits November 26, 2026 14:51
A degrade at a command boundary (capture_all, cap_exceeded, hold_budget,
replay mismatch, overlay read failure) voided the transaction's whole
pending timeline. A late capture_all, such as the first temp table of a
session inserting pg_temp_N after the last shape change, threw away exact
slots captured earlier. The commit shape then had to read the entire dirty
interval, and rows that were decodable got fenced.

Record where the timeline degraded. Slots before that boundary keep
answering. Capture fences the head run before the first slot against the
predecessor, as before, and the tail past the cut against the last recorded
shape. The drain decodes records at or past the cut under the commit-time
descriptor instead of the last slot, which could predate a change nothing
recorded.

Log every degrade path at WARN with xid, boundary and reason. Ambiguity
WARNs now name the published spans and the degrade boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A degraded transaction promotes its pre-cut slots, but the commit shape
kept valid_from at first_touch, below them. The log lookup takes the
latest valid_from at or before the LSN, so the tail past the cut and
every later transaction resolved to the last slot, and a shape change
the missed boundary made was silently lost (an added column decoded as
NULL). The drain's commit-time fallback reads the same lookup, so it hit
the same slot.

Also route the overlay-read degrade through the shared helper, drop the
unreachable empty-oids check in admits and the unread
PromotedXact::degraded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015qZNCjtC5YNrK2PtpvAGMZ
@serprex
serprex force-pushed the pending-degrade-cut branch from 1b37dbc to 808acc4 Compare November 26, 2026 14:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 808acc4. Configure here.

Comment thread src/catalog/pending.rs Resolved
Comment thread src/source/catalog_capture.rs Resolved

@security-ai-gate-reviewer security-ai-gate-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by the AI review gate on f1fcc11. Details in the approver's comment on this pull request.

@security-ai-gate-reviewer

Copy link
Copy Markdown

AI review gate — auto-approved

f1fcc11161f4 is approved by security-ai-gate-reviewer[bot], an automated identity, not a human. The approval stands on the required AI review: Cursor Bugbot concluded green on this commit and the AI review gate is SUCCESS (its own comment has the verdict), and the change touches no path that requires a human reviewer. It is bound to this commit: a new push dismisses it and the approver re-evaluates.

History (latest 5 heads, newest first)

  • f1fcc11161f4 approved — green: Cursor Bugbot

@serprex

serprex commented Nov 26, 2026

Copy link
Copy Markdown
Member

superceded by #365

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.

3 participants