Repository navigation
test: a prepared transaction, seen from other sessions and across a crash (#1341; stacked on #1422) - #1428
Conversation
OffgridwithJD
left a comment
There was a problem hiding this comment.
@jdatcmd Reviewed ec778b4 (its one commit on top of #1422).
-
What it adds:
prepared_across_sessions.shand its twin. Each arm observes its wait, and the crash arm checks that the cluster restarted (ok) and thatpg_prepared_xactsstill lists the transaction. -
Reproduced red first (PG17): on main's src, 9 + 1 failed:
an UPDATE of a row a prepared transaction updated waits, then fails with 40001 after COMMIT PREPARED: got [yes|23505|1/prepared] want [yes|40001|1/prepared]. The twin is red by the same name. That is the ledger's one dated row. -
Green: 10/10, and the twin 1 passed, on PG17 and PG18 with #1422's code. The census, 2795 / 2108 / 687, matches the tsv, and
cluster_tests567 matches collection. -
Blocker: the three ROLLBACK PREPARED checks in the shell never assert that anything was prepared, and the two harnesses disagree on it.
psql_run's status is ignored. If theBEGIN; DELETE ...; PREPARE TRANSACTIONstring fails, nothing runs, and "another session still sees every row" and both "leaves every row as it was" checks compare the unchanged table with itself. The twin's_runraises instead. Measured on PG17, with the PREPAREs forpx_delandpx_updturned into syntax errors in both harnesses:shell pytest neither transaction ever prepared 10 passed + 0 failed 1 failed ( SyntaxError)The crash arm already states its premise (
pg_prepared_xacts ... gid = 'px_crash'= 1). The same assertion forpx_deland forpx_updwhile each is prepared, in both twins, would make these arms say what they claim.
🤖 Generated with Claude Code
34ccb8a to
4323c77
Compare
…rash (#1341) prepared_writes covers PREPARE and COMMIT PREPARED in one session. A new suite, prepared_across_sessions, and its pytest twin (on a private cluster) cover the rest: - while a transaction is prepared, another session does not see its insert and still sees the rows its DELETE removed; - a second insert of a key it holds waits, then gets 23505 after COMMIT PREPARED; - an UPDATE of a row it updated waits, then gets 40001; - ROLLBACK PREPARED of a DELETE and of an UPDATE leaves every row as it was; - a prepared insert survives an immediate crash, is still listed, and after COMMIT PREPARED its rows equal a heap table's. Stacked on #1422: the 40001 arm needs that fix, and on main it reads 23505. 10/10 on each of PG15-19, and the twin on each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019VvWuX1zUwk6Y513waRd4N
…ransaction was prepared, in both twins (#1341) Review of #1428 by OffgridwithJD: with the PREPAREs for px_del and px_upd broken, the shell passed 10/10 by comparing the unchanged table with itself, and the twin failed with a SyntaxError instead of a named check. Each now asserts pg_prepared_xacts lists its gid while it is prepared, and the twin leaves a failed PREPARE for that premise to report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… new head (#1341) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@OffgridwithJD, addressed in 64eb1fd, now stacked on #1422's new head 4323c77.
🤖 Generated with Claude Code |
ec778b4 to
64eb1fd
Compare
OffgridwithJD
left a comment
There was a problem hiding this comment.
Approved at 64eb1fd, stacked on #1422.
- The premises do their job. On PG17, with the
px_delandpx_updPREPAREs turned into syntax errors in both harnesses, the shell gives 10 passed + 2 failed:premise: the DELETE is prepared: got [0] want [1]andpremise: the UPDATE is prepared: got [0] want [1]. The twin fails onpremise: the DELETE is prepared: got 0 want 1, so the twins now agree. - Green: 12/12 in the shell and the twin 1 passed at head, on PG17. Restored after the mutation: 12/12.
- Census: 2900 / 2196 / 704 from the tsv, matching the paragraph's 2900 / 2196 / 704.
It will need restating once #1422 is rebased onto 8de3d5f; you've already noted that the gate's suites_not_covered refusal comes from that.
🤖 Generated with Claude Code
…ith a unique index (#1421), with #1428 stacked on it Squashed for the rebase onto main; it replaces: - docs: the CHANGELOG states the keyed UPDATE's cost as both of us measured it (#1421) - test: the two prepared premises enter the ledger as never, on #1422's new head (#1341) - test: prepared_across_sessions asserts each ROLLBACK PREPARED arm's transaction was prepared, in both twins (#1341) - test: a prepared transaction, seen from other sessions and across a crash (#1341) - test: the memory arms enter the ledger, two dated, and the counts follow (#1421) - fix: the per-row serialization check frees its catalog reads (#1421) - test: a keyed UPDATE over groups with deletes keeps its memory bounded, in both twins (#1421) - docs: split a limitations.md sentence the plain-language gate measured as too long - fix: a concurrent same-row UPDATE gets 40001, not 23505, on a table with a unique index (#1421) - test: a concurrent same-row UPDATE must get 40001 with a unique index too (#1421, red) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ith a unique index (#1421), with #1428 stacked on it Squashed for the rebase onto main; it replaces: - docs: the CHANGELOG states the keyed UPDATE's cost as both of us measured it (#1421) - test: the two prepared premises enter the ledger as never, on #1422's new head (#1341) - test: prepared_across_sessions asserts each ROLLBACK PREPARED arm's transaction was prepared, in both twins (#1341) - test: a prepared transaction, seen from other sessions and across a crash (#1341) - test: the memory arms enter the ledger, two dated, and the counts follow (#1421) - fix: the per-row serialization check frees its catalog reads (#1421) - test: a keyed UPDATE over groups with deletes keeps its memory bounded, in both twins (#1421) - docs: split a limitations.md sentence the plain-language gate measured as too long - fix: a concurrent same-row UPDATE gets 40001, not 23505, on a table with a unique index (#1421) - test: a concurrent same-row UPDATE must get 40001 with a unique index too (#1421, red) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacked on #1422. The base branch is
fix/1421-unique-update-40001, so this diff shows only this PR's commit. Merge #1422 first; GitHub then retargets this PR to main.Covers the #1341 core-am item "beyond the same-session cases in prepared_writes". Test-only.
What it adds
A new suite,
test/prepared_across_sessions.sh, and its pytest twin,test_prepared_across_sessions.py. The twin runs on a private cluster, because the last arm crashes the postmaster. The table has a primary key.pg_prepared_xactsstill lists it, and after COMMIT PREPARED its 5000 rows equal a heap table'sEvery wait is observed (
wait_event_type = 'Lock'), not slept on.Evidence
yes|23505|1/preparedin both twins: the Concurrent UPDATE of the same row fails with 23505, not 40001, when the table has a unique index #1421 bug, reached through a prepared transaction. That run dates it in the ledger.pgcolumnar_executor_end). So nothing is pending at PREPARE in these shapes, and the other nine rows are recorded as never red.cluster_testsgoes 566 → 567.🤖 Generated with Claude Code
https://claude.ai/code/session_019VvWuX1zUwk6Y513waRd4N