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

Commiteb43bdb

Browse files
committed
Make detach-partition-concurrently-4 less timing sensitive
Same as5e0b1ae, for the companion test file.This one seems lower probability (only two failures in a month of runs);I was hardly able to reproduce a failure without a patch, so the factthat I was also unable to reproduce one with it doesn't say anything.We'll have to wait for further buildfarm results to see if we need anyfurther adjustments.Discussion:https://postgr.es/m/20210524090712.GA3771394@rfd.leadboat.com
1 parente30e3fd commiteb43bdb

File tree

2 files changed

+68
-51
lines changed

2 files changed

+68
-51
lines changed

‎src/test/isolation/expected/detach-partition-concurrently-4.out

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Parsed test spec with 3 sessions
22

3-
starting permutation: s2snitch s1b s1s s2detach s1cancel s1insert s1c
3+
starting permutation: s2snitch s1b s1s s2detach s1cancels2noops1insert s1c
44
step s2snitch: insert into d4_pid select pg_backend_pid();
55
step s1b: begin;
66
step s1s: select * from d4_primary;
@@ -9,12 +9,13 @@ a
99
1
1010
2
1111
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
12-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
13-
pg_cancel_backend
12+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
13+
pg_cancel_backendpg_sleep
1414

15-
t
15+
t
1616
step s2detach: <... completed>
1717
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
18+
step s2noop: UNLISTEN noop;
1819
step s1insert: insert into d4_fk values (1);
1920
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
2021
step s1c: commit;
@@ -33,7 +34,7 @@ step s2detach: <... completed>
3334
error in steps s1insert s2detach: ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
3435
step s1c: commit;
3536

36-
starting permutation: s2snitch s1brr s1s s2detach s1cancel s1insert s1c
37+
starting permutation: s2snitch s1brr s1s s2detach s1cancels2noops1insert s1c
3738
step s2snitch: insert into d4_pid select pg_backend_pid();
3839
step s1brr: begin isolation level repeatable read;
3940
step s1s: select * from d4_primary;
@@ -42,12 +43,13 @@ a
4243
1
4344
2
4445
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
45-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
46-
pg_cancel_backend
46+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
47+
pg_cancel_backendpg_sleep
4748

48-
t
49+
t
4950
step s2detach: <... completed>
5051
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
52+
step s2noop: UNLISTEN noop;
5153
step s1insert: insert into d4_fk values (1);
5254
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
5355
step s1c: commit;
@@ -66,17 +68,18 @@ step s2detach: <... completed>
6668
error in steps s1insert s2detach: ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
6769
step s1c: commit;
6870

69-
starting permutation: s2snitch s1b s1declare s2detach s1cancel s1fetchall s1insert s1c
71+
starting permutation: s2snitch s1b s1declare s2detach s1cancels2noops1fetchall s1insert s1c
7072
step s2snitch: insert into d4_pid select pg_backend_pid();
7173
step s1b: begin;
7274
step s1declare: declare f cursor for select * from d4_primary;
7375
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
74-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
75-
pg_cancel_backend
76+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
77+
pg_cancel_backendpg_sleep
7678

77-
t
79+
t
7880
step s2detach: <... completed>
7981
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
82+
step s2noop: UNLISTEN noop;
8083
step s1fetchall: fetch all from f;
8184
a
8285

@@ -101,17 +104,18 @@ step s2detach: <... completed>
101104
error in steps s1insert s2detach: ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
102105
step s1c: commit;
103106

104-
starting permutation: s2snitch s1b s1declare s2detach s1cancel s1svpt s1insert s1rollback s1fetchall s1c
107+
starting permutation: s2snitch s1b s1declare s2detach s1cancels2noops1svpt s1insert s1rollback s1fetchall s1c
105108
step s2snitch: insert into d4_pid select pg_backend_pid();
106109
step s1b: begin;
107110
step s1declare: declare f cursor for select * from d4_primary;
108111
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
109-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
110-
pg_cancel_backend
112+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
113+
pg_cancel_backendpg_sleep
111114

112-
t
115+
t
113116
step s2detach: <... completed>
114117
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
118+
step s2noop: UNLISTEN noop;
115119
step s1svpt: savepoint f;
116120
step s1insert: insert into d4_fk values (1);
117121
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
@@ -140,15 +144,16 @@ a
140144
step s1c: commit;
141145
step s2detach: <... completed>
142146

143-
starting permutation: s2snitch s1b s2detach s1declare s1cancel s1fetchall s1insert s1c
147+
starting permutation: s2snitch s1b s2detach s1declare s1cancels2noops1fetchall s1insert s1c
144148
step s2snitch: insert into d4_pid select pg_backend_pid();
145149
step s1b: begin;
146150
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently;
147151
step s1declare: declare f cursor for select * from d4_primary;
148-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
149-
pg_cancel_backend
152+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
153+
pg_cancel_backendpg_sleep
150154

151-
t
155+
t
156+
step s2noop: UNLISTEN noop;
152157
step s1fetchall: fetch all from f;
153158
a
154159

@@ -170,15 +175,16 @@ step s1insert: insert into d4_fk values (1);
170175
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
171176
step s1c: commit;
172177

173-
starting permutation: s2snitch s1b s2detach s1declare s1cancel s1svpt s1insert s1rollback s1fetchall s1c
178+
starting permutation: s2snitch s1b s2detach s1declare s1cancels2noops1svpt s1insert s1rollback s1fetchall s1c
174179
step s2snitch: insert into d4_pid select pg_backend_pid();
175180
step s1b: begin;
176181
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently;
177182
step s1declare: declare f cursor for select * from d4_primary;
178-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
179-
pg_cancel_backend
183+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
184+
pg_cancel_backendpg_sleep
180185

181-
t
186+
t
187+
step s2noop: UNLISTEN noop;
182188
step s1svpt: savepoint f;
183189
step s1insert: insert into d4_fk values (1);
184190
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
@@ -204,7 +210,7 @@ a
204210
2
205211
step s1c: commit;
206212

207-
starting permutation: s2snitch s1brr s1declare2 s1fetchone s2detach s1cancel s1updcur s1c
213+
starting permutation: s2snitch s1brr s1declare2 s1fetchone s2detach s1cancels2noops1updcur s1c
208214
step s2snitch: insert into d4_pid select pg_backend_pid();
209215
step s1brr: begin isolation level repeatable read;
210216
step s1declare2: declare f cursor for select * from d4_fk where a = 2;
@@ -213,12 +219,13 @@ a
213219

214220
2
215221
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
216-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
217-
pg_cancel_backend
222+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
223+
pg_cancel_backendpg_sleep
218224

219-
t
225+
t
220226
step s2detach: <... completed>
221227
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
228+
step s2noop: UNLISTEN noop;
222229
step s1updcur: update d4_fk set a = 1 where current of f;
223230
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
224231
step s1c: commit;
@@ -265,7 +272,7 @@ ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk
265272
step s1c: commit;
266273
step s2detach: <... completed>
267274

268-
starting permutation: s2snitch s1b s1s s2detach s3brr s3insert s3commit s1cancel s1c
275+
starting permutation: s2snitch s1b s1s s2detach s3brr s3insert s3commit s1cancels2noops1c
269276
step s2snitch: insert into d4_pid select pg_backend_pid();
270277
step s1b: begin;
271278
step s1s: select * from d4_primary;
@@ -278,12 +285,13 @@ step s3brr: begin isolation level repeatable read;
278285
step s3insert: insert into d4_fk values (1);
279286
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
280287
step s3commit: commit;
281-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
282-
pg_cancel_backend
288+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
289+
pg_cancel_backendpg_sleep
283290

284-
t
291+
t
285292
step s2detach: <... completed>
286293
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
294+
step s2noop: UNLISTEN noop;
287295
step s1c: commit;
288296

289297
starting permutation: s2snitch s1b s1s s2detach s3brr s3insert s3commit s1c
@@ -302,7 +310,7 @@ step s3commit: commit;
302310
step s1c: commit;
303311
step s2detach: <... completed>
304312

305-
starting permutation: s2snitch s1brr s1s s2detach s1cancel s3vacfreeze s1s s1insert s1c
313+
starting permutation: s2snitch s1brr s1s s2detach s1cancels2noops3vacfreeze s1s s1insert s1c
306314
step s2snitch: insert into d4_pid select pg_backend_pid();
307315
step s1brr: begin isolation level repeatable read;
308316
step s1s: select * from d4_primary;
@@ -311,12 +319,13 @@ a
311319
1
312320
2
313321
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
314-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
315-
pg_cancel_backend
322+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
323+
pg_cancel_backendpg_sleep
316324

317-
t
325+
t
318326
step s2detach: <... completed>
319327
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
328+
step s2noop: UNLISTEN noop;
320329
step s3vacfreeze: vacuum freeze pg_catalog.pg_inherits;
321330
step s1s: select * from d4_primary;
322331
a
@@ -327,7 +336,7 @@ step s1insert: insert into d4_fk values (1);
327336
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
328337
step s1c: commit;
329338

330-
starting permutation: s2snitch s1b s1s s2detach s1cancel s3vacfreeze s1s s1insert s1c
339+
starting permutation: s2snitch s1b s1s s2detach s1cancels2noops3vacfreeze s1s s1insert s1c
331340
step s2snitch: insert into d4_pid select pg_backend_pid();
332341
step s1b: begin;
333342
step s1s: select * from d4_primary;
@@ -336,12 +345,13 @@ a
336345
1
337346
2
338347
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
339-
step s1cancel: select pg_cancel_backend(pid) from d4_pid;
340-
pg_cancel_backend
348+
step s1cancel: select pg_cancel_backend(pid), pg_sleep(0.1) from d4_pid;
349+
pg_cancel_backendpg_sleep
341350

342-
t
351+
t
343352
step s2detach: <... completed>
344353
error in steps s1cancel s2detach: ERROR: canceling statement due to user request
354+
step s2noop: UNLISTEN noop;
345355
step s3vacfreeze: vacuum freeze pg_catalog.pg_inherits;
346356
step s1s: select * from d4_primary;
347357
a

‎src/test/isolation/specs/detach-partition-concurrently-4.spec

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# (The cases where the detaching transaction is cancelled is interesting
44
# because the locking situation is completely different. I didn't verify
55
# that keeping both variants adds any extra coverage.)
6+
#
7+
# Note: Always keep "s2noop" right after "s1cancel" in permutations. This
8+
# reduces the probability of the timing problem that the cancel error report
9+
# is shown together with the next query instead of with the cancel query.
10+
611
setup {
712
droptableifexistsd4_primary,d4_primary1,d4_fk,d4_pid;
813
createtabled4_primary (aintprimarykey)partitionbylist (a);
@@ -19,7 +24,8 @@ session "s1"
1924
step"s1b"{begin; }
2025
step"s1brr"{beginisolationlevelrepeatableread; }
2126
step"s1s"{select*fromd4_primary; }
22-
step"s1cancel" {selectpg_cancel_backend(pid)fromd4_pid; }
27+
# Sleep 0.1s after sending cancel, to give s2 time to react
28+
step"s1cancel" {selectpg_cancel_backend(pid),pg_sleep(0.1)fromd4_pid; }
2329
step"s1insert"{insertintod4_fkvalues (1); }
2430
step"s1c"{commit; }
2531
step"s1declare"{declarefcursorforselect*fromd4_primary; }
@@ -33,6 +39,7 @@ step "s1rollback"{ rollback to f; }
3339
session"s2"
3440
step"s2snitch" {insertintod4_pidselectpg_backend_pid(); }
3541
step"s2detach" {altertabled4_primarydetachpartitiond4_primary1concurrently; }
42+
step"s2noop"{UNLISTENnoop; }
3643

3744
session"s3"
3845
step"s3brr"{beginisolationlevelrepeatableread; }
@@ -41,34 +48,34 @@ step "s3commit"{ commit; }
4148
step"s3vacfreeze"{vacuumfreezepg_catalog.pg_inherits; }
4249

4350
# Trying to insert into a partially detached partition is rejected
44-
permutation"s2snitch""s1b""s1s""s2detach""s1cancel""s1insert""s1c"
51+
permutation"s2snitch""s1b""s1s""s2detach""s1cancel""s2noop""s1insert""s1c"
4552
permutation"s2snitch""s1b""s1s""s2detach""s1insert""s1c"
4653
# ... even under REPEATABLE READ mode.
47-
permutation"s2snitch""s1brr""s1s""s2detach""s1cancel""s1insert""s1c"
54+
permutation"s2snitch""s1brr""s1s""s2detach""s1cancel""s2noop""s1insert""s1c"
4855
permutation"s2snitch""s1brr""s1s""s2detach""s1insert""s1c"
4956

5057
# If you read the referenced table using a cursor, you can see a row that the
5158
# RI query does not see.
52-
permutation"s2snitch""s1b""s1declare""s2detach""s1cancel""s1fetchall""s1insert""s1c"
59+
permutation"s2snitch""s1b""s1declare""s2detach""s1cancel""s2noop""s1fetchall""s1insert""s1c"
5360
permutation"s2snitch""s1b""s1declare""s2detach""s1fetchall""s1insert""s1c"
54-
permutation"s2snitch""s1b""s1declare""s2detach""s1cancel""s1svpt""s1insert""s1rollback""s1fetchall""s1c"
61+
permutation"s2snitch""s1b""s1declare""s2detach""s1cancel""s2noop""s1svpt""s1insert""s1rollback""s1fetchall""s1c"
5562
permutation"s2snitch""s1b""s1declare""s2detach""s1svpt""s1insert""s1rollback""s1fetchall""s1c"
56-
permutation"s2snitch""s1b""s2detach""s1declare""s1cancel""s1fetchall""s1insert""s1c"
63+
permutation"s2snitch""s1b""s2detach""s1declare""s1cancel""s2noop""s1fetchall""s1insert""s1c"
5764
permutation"s2snitch""s1b""s2detach""s1declare""s1fetchall""s1insert""s1c"
58-
permutation"s2snitch""s1b""s2detach""s1declare""s1cancel""s1svpt""s1insert""s1rollback""s1fetchall""s1c"
65+
permutation"s2snitch""s1b""s2detach""s1declare""s1cancel""s2noop""s1svpt""s1insert""s1rollback""s1fetchall""s1c"
5966
permutation"s2snitch""s1b""s2detach""s1declare""s1svpt""s1insert""s1rollback""s1fetchall""s1c"
6067

6168
# Creating the referencing row using a cursor
62-
permutation"s2snitch""s1brr""s1declare2""s1fetchone""s2detach""s1cancel""s1updcur""s1c"
69+
permutation"s2snitch""s1brr""s1declare2""s1fetchone""s2detach""s1cancel""s2noop""s1updcur""s1c"
6370
permutation"s2snitch""s1brr""s1declare2""s1fetchone""s2detach""s1updcur""s1c"
6471
permutation"s2snitch""s1brr""s1declare2""s1fetchone""s1updcur""s2detach""s1c"
6572

6673
# Try reading the table from an independent session.
6774
permutation"s2snitch""s1b""s1s""s2detach""s3insert""s1c"
68-
permutation"s2snitch""s1b""s1s""s2detach""s3brr""s3insert""s3commit""s1cancel""s1c"
75+
permutation"s2snitch""s1b""s1s""s2detach""s3brr""s3insert""s3commit""s1cancel""s2noop""s1c"
6976
permutation"s2snitch""s1b""s1s""s2detach""s3brr""s3insert""s3commit""s1c"
7077

7178
# Try one where we VACUUM FREEZE pg_inherits (to verify that xmin change is
7279
# handled correctly).
73-
permutation"s2snitch""s1brr""s1s""s2detach""s1cancel""s3vacfreeze""s1s""s1insert""s1c"
74-
permutation"s2snitch""s1b""s1s""s2detach""s1cancel""s3vacfreeze""s1s""s1insert""s1c"
80+
permutation"s2snitch""s1brr""s1s""s2detach""s1cancel""s2noop""s3vacfreeze""s1s""s1insert""s1c"
81+
permutation"s2snitch""s1b""s1s""s2detach""s1cancel""s2noop""s3vacfreeze""s1s""s1insert""s1c"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp