| 1 |
# Test for interactions between SSI's "conflict out" handling for heapam and |
| 2 |
# concurrently updated tuple |
| 3 |
# |
| 4 |
# See bug report: |
| 5 |
# https://postgr.es/m/db7b729d-0226-d162-a126-8a8ab2dc4443%40jepsen.io |
| 6 |
|
| 7 |
setup |
| 8 |
{ |
| 9 |
CREATE TABLE txn0(id int4 PRIMARY KEY, val TEXT); |
| 10 |
CREATE TABLE txn1(id int4 PRIMARY KEY, val TEXT); |
| 11 |
} |
| 12 |
|
| 13 |
teardown |
| 14 |
{ |
| 15 |
DROP TABLE txn0; |
| 16 |
DROP TABLE txn1; |
| 17 |
} |
| 18 |
|
| 19 |
session foo |
| 20 |
setup { BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; } |
| 21 |
step foo_select { SELECT * FROM txn0 WHERE id = 42; } |
| 22 |
step foo_insert { INSERT INTO txn1 SELECT 7, 'foo_insert'; } |
| 23 |
step foo_commit { COMMIT; } |
| 24 |
|
| 25 |
session bar |
| 26 |
setup { BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; } |
| 27 |
step bar_select { SELECT * FROM txn1 WHERE id = 7; } |
| 28 |
step bar_insert { INSERT INTO txn0 SELECT 42, 'bar_insert'; } |
| 29 |
step bar_commit { COMMIT; } |
| 30 |
|
| 31 |
# This session creates the conditions that confused bar's "conflict out" |
| 32 |
# handling in old releases affected by bug: |
| 33 |
session trouble |
| 34 |
setup { BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; } |
| 35 |
step trouble_update { UPDATE txn1 SET val = 'add physical version for "bar_select"' WHERE id = 7; } |
| 36 |
step trouble_delete { DELETE FROM txn1 WHERE id = 7; } |
| 37 |
step trouble_abort { ABORT; } |
| 38 |
|
| 39 |
permutation foo_select |
| 40 |
bar_insert |
| 41 |
foo_insert foo_commit |
| 42 |
trouble_update # Updates tuple... |
| 43 |
bar_select # Should observe one distinct XID per version |
| 44 |
bar_commit # "bar" should fail here at the latest |
| 45 |
trouble_abort |
| 46 |
|
| 47 |
# Same as above, but "trouble" session DELETEs this time around |
| 48 |
permutation foo_select |
| 49 |
bar_insert |
| 50 |
foo_insert foo_commit |
| 51 |
trouble_delete # Deletes tuple... |
| 52 |
bar_select # Should observe foo's XID |
| 53 |
bar_commit # "bar" should fail here at the latest |
| 54 |
trouble_abort |