Repository navigation
Keep pending coverage across a late degrade - #360
Amogh-Bharadwaj wants to merge 3 commits into
Conversation
de0911e to
1b37dbc
Compare
AI review gate — AI review passedClean review from: Cursor Bugbot. |
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
1b37dbc to
808acc4
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ 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.
…ll try make preceeding PRs to open way
There was a problem hiding this comment.
Auto-approved by the AI review gate on f1fcc11. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
|
superceded by #365 |

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_NafterSET NOT NULL. That boundary hitcapture_all, which discarded the exact slot captured right afterADD 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:
PendingCatalogrecords the boundary where the timeline degraded (degraded_at). Slots before it keep answering, and the earliest position wins across subtransactions.in_place_verdictfences 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.Tests:
late_capture_all_keeps_the_earlier_timeline(isolates this fix) andbackfill_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_atat the boundary that caused the cut; slots captured before that boundary stay usable, with the earliest cut winning across subtransactions.PendingSlotgainscaptured_atso ordering and cuts follow where shapes were read, not onlyvalid_from.Commit capture and decoding follow the partial timeline.
PromotedXactexposesCoverage(from / until / last shape) instead of treating any degrade as total loss.in_place_verdictfences the pre-slot head against the predecessor and, when needed, the post-cut tail against the last recorded shape.commit_entrieslands the commit descriptor at the cut when a promoted slot would otherwise keep answering past it. The drain storespending_untiland 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 latecapture_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.