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

Commit65aae93

Browse files
committed
Improve test coverage for changes to inplace-updated catalogs.
This covers both regular and inplace changes, since bugs arise at theirintersection. Where marked, these witness extant bugs. Back-patch tov12 (all supported versions).Reviewed (in an earlier version) by Robert Haas.Discussion:https://postgr.es/m/20240512232923.aa.nmisch@google.com
1 parent86fac88 commit65aae93

13 files changed

+609
-1
lines changed

‎src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,34 @@ sub pgbench
8282
"CREATE TYPE pg_temp.e AS ENUM ($labels); DROP TYPE pg_temp.e;"
8383
});
8484

85+
# Test inplace updates from VACUUM concurrent with heap_update from GRANT.
86+
# The PROC_IN_VACUUM environment can't finish MVCC table scans consistently,
87+
# so this fails rarely. To reproduce consistently, add a sleep after
88+
# GetCatalogSnapshot(non-catalog-rel).
89+
Test::More->builder->todo_start('PROC_IN_VACUUM scan breakage');
90+
$node->safe_psql('postgres','CREATE TABLE ddl_target ()');
91+
$node->pgbench(
92+
'--no-vacuum --client=5 --protocol=prepared --transactions=50',
93+
0,
94+
[qr{processed: 250/250}],
95+
[qr{^$}],
96+
'concurrent GRANT/VACUUM',
97+
{
98+
'001_pgbench_grant@9'=>q(
99+
DO $$
100+
BEGIN
101+
PERFORM pg_advisory_xact_lock(42);
102+
FOR i IN 1 .. 10 LOOP
103+
GRANT SELECT ON ddl_target TO PUBLIC;
104+
REVOKE SELECT ON ddl_target FROM PUBLIC;
105+
END LOOP;
106+
END
107+
$$;
108+
),
109+
'001_pgbench_vacuum_ddl_target@1'=>"VACUUM ddl_target;",
110+
});
111+
Test::More->builder->todo_end;
112+
85113
# Trigger various connection errors
86114
pgbench(
87115
'no-such-database',

‎src/test/isolation/expected/eval-plan-qual.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,3 +1307,15 @@ a|b|c|d
13071307
2|2|2|4
13081308
(2 rows)
13091309

1310+
1311+
starting permutation: sys1 sysupd2 c1 c2
1312+
step sys1:
1313+
UPDATE pg_class SET reltuples = 123 WHERE oid = 'accounts'::regclass;
1314+
1315+
step sysupd2:
1316+
UPDATE pg_class SET reltuples = reltuples * 2
1317+
WHERE oid = 'accounts'::regclass;
1318+
<waiting ...>
1319+
step c1: COMMIT;
1320+
step sysupd2: <... completed>
1321+
step c2: COMMIT;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Parsed test spec with 3 sessions
2+
3+
starting permutation: cachefill3 cir1 cic2 ddl3 read1
4+
step cachefill3: TABLE newly_indexed;
5+
c
6+
-
7+
(0 rows)
8+
9+
step cir1: BEGIN; CREATE INDEX i1 ON newly_indexed (c); ROLLBACK;
10+
step cic2: CREATE INDEX i2 ON newly_indexed (c);
11+
step ddl3: ALTER TABLE newly_indexed ADD extra int;
12+
step read1:
13+
SELECT relhasindex FROM pg_class WHERE oid = 'newly_indexed'::regclass;
14+
15+
relhasindex
16+
-----------
17+
f
18+
(1 row)
19+
20+
21+
starting permutation: cir1 cic2 ddl3 read1
22+
step cir1: BEGIN; CREATE INDEX i1 ON newly_indexed (c); ROLLBACK;
23+
step cic2: CREATE INDEX i2 ON newly_indexed (c);
24+
step ddl3: ALTER TABLE newly_indexed ADD extra int;
25+
step read1:
26+
SELECT relhasindex FROM pg_class WHERE oid = 'newly_indexed'::regclass;
27+
28+
relhasindex
29+
-----------
30+
t
31+
(1 row)
32+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Parsed test spec with 3 sessions
2+
3+
starting permutation: snap3 b1 grant1 vac2 snap3 c1 cmp3
4+
step snap3:
5+
INSERT INTO frozen_witness
6+
SELECT datfrozenxid FROM pg_database WHERE datname = current_catalog;
7+
8+
step b1: BEGIN;
9+
step grant1:
10+
GRANT TEMP ON DATABASE isolation_regression TO regress_temp_grantee;
11+
12+
step vac2: VACUUM (FREEZE);
13+
step snap3:
14+
INSERT INTO frozen_witness
15+
SELECT datfrozenxid FROM pg_database WHERE datname = current_catalog;
16+
17+
step c1: COMMIT;
18+
step cmp3:
19+
SELECT 'datfrozenxid retreated'
20+
FROM pg_database
21+
WHERE datname = current_catalog
22+
AND age(datfrozenxid) > (SELECT min(age(x)) FROM frozen_witness);
23+
24+
?column?
25+
----------------------
26+
datfrozenxid retreated
27+
(1 row)
28+
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
Parsed test spec with 5 sessions
2+
3+
starting permutation: b1 grant1 read2 addk2 c1 read2
4+
step b1: BEGIN;
5+
step grant1:
6+
GRANT SELECT ON intra_grant_inplace TO PUBLIC;
7+
8+
step read2:
9+
SELECT relhasindex FROM pg_class
10+
WHERE oid = 'intra_grant_inplace'::regclass;
11+
12+
relhasindex
13+
-----------
14+
f
15+
(1 row)
16+
17+
step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c);
18+
step c1: COMMIT;
19+
step read2:
20+
SELECT relhasindex FROM pg_class
21+
WHERE oid = 'intra_grant_inplace'::regclass;
22+
23+
relhasindex
24+
-----------
25+
f
26+
(1 row)
27+
28+
29+
starting permutation: keyshr5 addk2
30+
step keyshr5:
31+
SELECT relhasindex FROM pg_class
32+
WHERE oid = 'intra_grant_inplace'::regclass FOR KEY SHARE;
33+
34+
relhasindex
35+
-----------
36+
f
37+
(1 row)
38+
39+
step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c);
40+
41+
starting permutation: keyshr5 b3 sfnku3 addk2 r3
42+
step keyshr5:
43+
SELECT relhasindex FROM pg_class
44+
WHERE oid = 'intra_grant_inplace'::regclass FOR KEY SHARE;
45+
46+
relhasindex
47+
-----------
48+
f
49+
(1 row)
50+
51+
step b3: BEGIN ISOLATION LEVEL READ COMMITTED;
52+
step sfnku3:
53+
SELECT relhasindex FROM pg_class
54+
WHERE oid = 'intra_grant_inplace'::regclass FOR NO KEY UPDATE;
55+
56+
relhasindex
57+
-----------
58+
f
59+
(1 row)
60+
61+
step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c);
62+
step r3: ROLLBACK;
63+
64+
starting permutation: b2 sfnku2 addk2 c2
65+
step b2: BEGIN;
66+
step sfnku2:
67+
SELECT relhasindex FROM pg_class
68+
WHERE oid = 'intra_grant_inplace'::regclass FOR NO KEY UPDATE;
69+
70+
relhasindex
71+
-----------
72+
f
73+
(1 row)
74+
75+
step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c);
76+
step c2: COMMIT;
77+
78+
starting permutation: keyshr5 b2 sfnku2 addk2 c2
79+
step keyshr5:
80+
SELECT relhasindex FROM pg_class
81+
WHERE oid = 'intra_grant_inplace'::regclass FOR KEY SHARE;
82+
83+
relhasindex
84+
-----------
85+
f
86+
(1 row)
87+
88+
step b2: BEGIN;
89+
step sfnku2:
90+
SELECT relhasindex FROM pg_class
91+
WHERE oid = 'intra_grant_inplace'::regclass FOR NO KEY UPDATE;
92+
93+
relhasindex
94+
-----------
95+
f
96+
(1 row)
97+
98+
step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c);
99+
step c2: COMMIT;
100+
101+
starting permutation: b3 sfu3 b1 grant1 read2 addk2 r3 c1 read2
102+
step b3: BEGIN ISOLATION LEVEL READ COMMITTED;
103+
step sfu3:
104+
SELECT relhasindex FROM pg_class
105+
WHERE oid = 'intra_grant_inplace'::regclass FOR UPDATE;
106+
107+
relhasindex
108+
-----------
109+
f
110+
(1 row)
111+
112+
step b1: BEGIN;
113+
step grant1:
114+
GRANT SELECT ON intra_grant_inplace TO PUBLIC;
115+
<waiting ...>
116+
step read2:
117+
SELECT relhasindex FROM pg_class
118+
WHERE oid = 'intra_grant_inplace'::regclass;
119+
120+
relhasindex
121+
-----------
122+
f
123+
(1 row)
124+
125+
step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c);
126+
step r3: ROLLBACK;
127+
step grant1: <... completed>
128+
step c1: COMMIT;
129+
step read2:
130+
SELECT relhasindex FROM pg_class
131+
WHERE oid = 'intra_grant_inplace'::regclass;
132+
133+
relhasindex
134+
-----------
135+
f
136+
(1 row)
137+
138+
139+
starting permutation: b2 sfnku2 b1 grant1 addk2 c2 c1 read2
140+
step b2: BEGIN;
141+
step sfnku2:
142+
SELECT relhasindex FROM pg_class
143+
WHERE oid = 'intra_grant_inplace'::regclass FOR NO KEY UPDATE;
144+
145+
relhasindex
146+
-----------
147+
f
148+
(1 row)
149+
150+
step b1: BEGIN;
151+
step grant1:
152+
GRANT SELECT ON intra_grant_inplace TO PUBLIC;
153+
<waiting ...>
154+
step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c);
155+
step c2: COMMIT;
156+
step grant1: <... completed>
157+
step c1: COMMIT;
158+
step read2:
159+
SELECT relhasindex FROM pg_class
160+
WHERE oid = 'intra_grant_inplace'::regclass;
161+
162+
relhasindex
163+
-----------
164+
f
165+
(1 row)
166+
167+
168+
starting permutation: b1 grant1 b3 sfu3 revoke4 c1 r3
169+
step b1: BEGIN;
170+
step grant1:
171+
GRANT SELECT ON intra_grant_inplace TO PUBLIC;
172+
173+
step b3: BEGIN ISOLATION LEVEL READ COMMITTED;
174+
step sfu3:
175+
SELECT relhasindex FROM pg_class
176+
WHERE oid = 'intra_grant_inplace'::regclass FOR UPDATE;
177+
<waiting ...>
178+
step revoke4:
179+
DO $$
180+
BEGIN
181+
REVOKE SELECT ON intra_grant_inplace FROM PUBLIC;
182+
EXCEPTION WHEN others THEN
183+
RAISE WARNING 'got: %', regexp_replace(sqlerrm, '[0-9]+', 'REDACTED');
184+
END
185+
$$;
186+
<waiting ...>
187+
step c1: COMMIT;
188+
step sfu3: <... completed>
189+
relhasindex
190+
-----------
191+
f
192+
(1 row)
193+
194+
s4: WARNING: got: tuple concurrently updated
195+
step revoke4: <... completed>
196+
step r3: ROLLBACK;
197+
198+
starting permutation: b1 drop1 b3 sfu3 revoke4 c1 r3
199+
step b1: BEGIN;
200+
step drop1:
201+
DROP TABLE intra_grant_inplace;
202+
203+
step b3: BEGIN ISOLATION LEVEL READ COMMITTED;
204+
step sfu3:
205+
SELECT relhasindex FROM pg_class
206+
WHERE oid = 'intra_grant_inplace'::regclass FOR UPDATE;
207+
<waiting ...>
208+
step revoke4:
209+
DO $$
210+
BEGIN
211+
REVOKE SELECT ON intra_grant_inplace FROM PUBLIC;
212+
EXCEPTION WHEN others THEN
213+
RAISE WARNING 'got: %', regexp_replace(sqlerrm, '[0-9]+', 'REDACTED');
214+
END
215+
$$;
216+
<waiting ...>
217+
step c1: COMMIT;
218+
step sfu3: <... completed>
219+
relhasindex
220+
-----------
221+
(0 rows)
222+
223+
s4: WARNING: got: tuple concurrently deleted
224+
step revoke4: <... completed>
225+
step r3: ROLLBACK;

‎src/test/isolation/isolation_schedule

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ test: fk-partitioned-1
3131
test: fk-partitioned-2
3232
test: eval-plan-qual
3333
test: eval-plan-qual-trigger
34+
test: inplace-inval
35+
test: intra-grant-inplace
36+
test: intra-grant-inplace-db
3437
test: lock-update-delete
3538
test: lock-update-traversal
3639
test: inherit-temp

‎src/test/isolation/specs/eval-plan-qual.spec

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ step simplepartupdate_noroute {
190190
updateparttblsetb=2wherec=1returning*;
191191
}
192192

193+
# test system class updates
194+
195+
stepsys1{
196+
UPDATEpg_classSETreltuples=123WHEREoid='accounts'::regclass;
197+
}
198+
193199

194200
sessions2
195201
setup{BEGINISOLATIONLEVELREADCOMMITTED; }
@@ -278,6 +284,11 @@ step wnested2 {
278284
);
279285
}
280286

287+
stepsysupd2{
288+
UPDATEpg_classSETreltuples=reltuples*2
289+
WHEREoid='accounts'::regclass;
290+
}
291+
281292
stepc2{COMMIT; }
282293
stepr2{ROLLBACK; }
283294

@@ -374,3 +385,5 @@ permutation simplepartupdate complexpartupdate c1 c2 read_part
374385
permutationsimplepartupdate_route1to2complexpartupdate_route_err1c1c2read_part
375386
permutationsimplepartupdate_noroutecomplexpartupdate_routec1c2read_part
376387
permutationsimplepartupdate_noroutecomplexpartupdate_doesnt_routec1c2read_part
388+
389+
permutationsys1sysupd2c1c2

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp