| 1 |
# Test that erroring out during logical slot creation is handled properly |
| 2 |
|
| 3 |
session "s1" |
| 4 |
setup { SET synchronous_commit=on; } |
| 5 |
|
| 6 |
step s1_b { BEGIN; } |
| 7 |
step s1_xid { SELECT 'xid' FROM txid_current(); } |
| 8 |
step s1_c { COMMIT; } |
| 9 |
step s1_cancel_s2 { |
| 10 |
SELECT pg_cancel_backend(pid) |
| 11 |
FROM pg_stat_activity |
| 12 |
WHERE application_name = 'isolation/slot_creation_error/s2'; |
| 13 |
} |
| 14 |
|
| 15 |
step s1_terminate_s2 { |
| 16 |
SELECT pg_terminate_backend(pid) |
| 17 |
FROM pg_stat_activity |
| 18 |
WHERE application_name = 'isolation/slot_creation_error/s2'; |
| 19 |
} |
| 20 |
|
| 21 |
step s1_view_slot { |
| 22 |
SELECT slot_name, slot_type, active FROM pg_replication_slots WHERE slot_name = 'slot_creation_error' |
| 23 |
} |
| 24 |
|
| 25 |
step s1_drop_slot { |
| 26 |
SELECT pg_drop_replication_slot('slot_creation_error'); |
| 27 |
} |
| 28 |
|
| 29 |
session s2 |
| 30 |
setup { SET synchronous_commit=on; } |
| 31 |
step s2_init { |
| 32 |
SELECT 'init' FROM pg_create_logical_replication_slot('slot_creation_error', 'test_decoding'); |
| 33 |
} |
| 34 |
|
| 35 |
# The tests first start a transaction with an xid assigned in s1, then create |
| 36 |
# a slot in s2. The slot creation waits for s1's transaction to end. Instead |
| 37 |
# we cancel / terminate s2. |
| 38 |
permutation s1_b s1_xid s2_init s1_view_slot s1_cancel_s2(s2_init) s1_view_slot s1_c |
| 39 |
permutation s1_b s1_xid s2_init s1_c s1_view_slot s1_drop_slot # check slot creation still works |
| 40 |
permutation s1_b s1_xid s2_init s1_terminate_s2(s2_init) s1_c s1_view_slot |
| 41 |
# can't run tests after this, due to s2's connection failure |