Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit278cdea

Browse files
committed
Add isolation test for errors during logical slot creation.
I didn't include this test in2f6501f, because I was not sure the errormessages for the terminated connection is stable across platforms. But itsounds like it is, and if not, we'd want to do something about the instabilityanyway...Discussion:https://postgr.es/m/CAD21AoDAeEpAbZEyYJsPZJUmSPaRicVSBObaL7sPaofnKz+9zg@mail.gmail.com
1 parenta4e1deb commit278cdea

File tree

3 files changed

+155
-1
lines changed

3 files changed

+155
-1
lines changed

‎contrib/test_decoding/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ REGRESS = ddl xact rewrite toast permissions decoding_in_xact \
99
sequence
1010
ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml\
1111
oldest_xmin snapshot_transfer subxact_without_top concurrent_stream\
12-
twophase_snapshot
12+
twophase_snapshot slot_creation_error
1313

1414
REGRESS_OPTS = --temp-config$(top_srcdir)/contrib/test_decoding/logical.conf
1515
ISOLATION_OPTS = --temp-config$(top_srcdir)/contrib/test_decoding/logical.conf
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: s1_b s1_xid s2_init s1_view_slot s1_cancel_s2 s1_view_slot s1_c
4+
step s1_b: BEGIN;
5+
step s1_xid: SELECT 'xid' FROM txid_current();
6+
?column?
7+
--------
8+
xid
9+
(1 row)
10+
11+
step s2_init:
12+
SELECT 'init' FROM pg_create_logical_replication_slot('slot_creation_error', 'test_decoding');
13+
<waiting ...>
14+
step s1_view_slot:
15+
SELECT slot_name, slot_type, active FROM pg_replication_slots WHERE slot_name = 'slot_creation_error'
16+
17+
slot_name |slot_type|active
18+
-------------------+---------+------
19+
slot_creation_error|logical |t
20+
(1 row)
21+
22+
step s1_cancel_s2:
23+
SELECT pg_cancel_backend(pid)
24+
FROM pg_stat_activity
25+
WHERE application_name = 'isolation/slot_creation_error/s2';
26+
27+
pg_cancel_backend
28+
-----------------
29+
t
30+
(1 row)
31+
32+
step s2_init: <... completed>
33+
ERROR: canceling statement due to user request
34+
step s1_view_slot:
35+
SELECT slot_name, slot_type, active FROM pg_replication_slots WHERE slot_name = 'slot_creation_error'
36+
37+
slot_name|slot_type|active
38+
---------+---------+------
39+
(0 rows)
40+
41+
step s1_c: COMMIT;
42+
43+
starting permutation: s1_b s1_xid s2_init s1_c s1_view_slot s1_drop_slot
44+
step s1_b: BEGIN;
45+
step s1_xid: SELECT 'xid' FROM txid_current();
46+
?column?
47+
--------
48+
xid
49+
(1 row)
50+
51+
step s2_init:
52+
SELECT 'init' FROM pg_create_logical_replication_slot('slot_creation_error', 'test_decoding');
53+
<waiting ...>
54+
step s1_c: COMMIT;
55+
step s2_init: <... completed>
56+
?column?
57+
--------
58+
init
59+
(1 row)
60+
61+
step s1_view_slot:
62+
SELECT slot_name, slot_type, active FROM pg_replication_slots WHERE slot_name = 'slot_creation_error'
63+
64+
slot_name |slot_type|active
65+
-------------------+---------+------
66+
slot_creation_error|logical |f
67+
(1 row)
68+
69+
step s1_drop_slot:
70+
SELECT pg_drop_replication_slot('slot_creation_error');
71+
72+
pg_drop_replication_slot
73+
------------------------
74+
75+
(1 row)
76+
77+
78+
starting permutation: s1_b s1_xid s2_init s1_terminate_s2 s1_c s1_view_slot
79+
step s1_b: BEGIN;
80+
step s1_xid: SELECT 'xid' FROM txid_current();
81+
?column?
82+
--------
83+
xid
84+
(1 row)
85+
86+
step s2_init:
87+
SELECT 'init' FROM pg_create_logical_replication_slot('slot_creation_error', 'test_decoding');
88+
<waiting ...>
89+
step s1_terminate_s2:
90+
SELECT pg_terminate_backend(pid)
91+
FROM pg_stat_activity
92+
WHERE application_name = 'isolation/slot_creation_error/s2';
93+
94+
pg_terminate_backend
95+
--------------------
96+
t
97+
(1 row)
98+
99+
step s2_init: <... completed>
100+
FATAL: terminating connection due to administrator command
101+
FATAL: terminating connection due to administrator command
102+
server closed the connection unexpectedly
103+
This probably means the server terminated abnormally
104+
before or while processing the request.
105+
106+
step s1_c: COMMIT;
107+
step s1_view_slot:
108+
SELECT slot_name, slot_type, active FROM pg_replication_slots WHERE slot_name = 'slot_creation_error'
109+
110+
slot_name|slot_type|active
111+
---------+---------+------
112+
(0 rows)
113+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Test that erroring out during logical slot creation is handled properly
2+
3+
session"s1"
4+
setup {SETsynchronous_commit=on; }
5+
6+
steps1_b {BEGIN; }
7+
steps1_xid {SELECT'xid'FROMtxid_current(); }
8+
steps1_c {COMMIT; }
9+
steps1_cancel_s2 {
10+
SELECTpg_cancel_backend(pid)
11+
FROMpg_stat_activity
12+
WHEREapplication_name='isolation/slot_creation_error/s2';
13+
}
14+
15+
steps1_terminate_s2 {
16+
SELECTpg_terminate_backend(pid)
17+
FROMpg_stat_activity
18+
WHEREapplication_name='isolation/slot_creation_error/s2';
19+
}
20+
21+
steps1_view_slot {
22+
SELECTslot_name,slot_type,activeFROMpg_replication_slotsWHEREslot_name='slot_creation_error'
23+
}
24+
25+
steps1_drop_slot {
26+
SELECTpg_drop_replication_slot('slot_creation_error');
27+
}
28+
29+
sessions2
30+
setup {SETsynchronous_commit=on; }
31+
steps2_init {
32+
SELECT'init'FROMpg_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+
permutations1_bs1_xids2_inits1_view_slots1_cancel_s2s1_view_slots1_c
39+
permutations1_bs1_xids2_inits1_cs1_view_slots1_drop_slot# check slot creation still works
40+
permutations1_bs1_xids2_inits1_terminate_s2s1_cs1_view_slot
41+
# can't run tests after this, due to s2's connection failure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp