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

Commit68f97ae

Browse files
committed
amcheck: Add a GIN index to the CREATE INDEX CONCURRENTLY tests
The existing CREATE INDEX CONCURRENTLY tests checking only B-Tree, butcan be cheaply extended to also check GIN. This helps increasing testcoverage for GIN amcheck, especially related to handling concurrent pagesplits and posting list trees.This already helped to identify several issues during development of theGIN amcheck support.Author: Mark Dilger <mark.dilger@enterprisedb.com>Reviewed-By: Tomas Vondra <tomas.vondra@enterprisedb.com>Reviewed-By: Kirill Reshke <reshkekirill@gmail.com>Discussion:https://postgr.es/m/BC221A56-977C-418E-A1B8-9EFC881D80C5%40enterprisedb.com
1 parentca738bd commit68f97ae

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

‎contrib/amcheck/t/002_cic.pl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
'lock_timeout =' . (1000 *$PostgreSQL::Test::Utils::timeout_default));
2222
$node->start;
2323
$node->safe_psql('postgres',q(CREATE EXTENSION amcheck));
24-
$node->safe_psql('postgres',q(CREATE TABLE tbl(i int)));
24+
$node->safe_psql('postgres',q(CREATE TABLE tbl(i int, j jsonb)));
2525
$node->safe_psql('postgres',q(CREATE INDEX idx ON tbl(i)));
26+
$node->safe_psql('postgres',q(CREATE INDEX ginidx ON tbl USING gin(j)));
2627

2728
#
2829
# Stress CIC with pgbench.
@@ -40,21 +41,24 @@
4041
{
4142
'002_pgbench_concurrent_transaction'=>q(
4243
BEGIN;
43-
INSERT INTO tbl VALUES(0);
44+
INSERT INTO tbl VALUES(0, '{"a":[["b",{"x":1}],["b",{"x":2}]],"c":3}');
4445
COMMIT;
4546
),
4647
'002_pgbench_concurrent_transaction_savepoints'=>q(
4748
BEGIN;
4849
SAVEPOINT s1;
49-
INSERT INTO tbl VALUES(0);
50+
INSERT INTO tbl VALUES(0, '[[14,2,3]]');
5051
COMMIT;
5152
),
5253
'002_pgbench_concurrent_cic'=>q(
5354
SELECT pg_try_advisory_lock(42)::integer AS gotlock \gset
5455
\if :gotlock
5556
DROP INDEX CONCURRENTLY idx;
5657
CREATE INDEX CONCURRENTLY idx ON tbl(i);
58+
DROP INDEX CONCURRENTLY ginidx;
59+
CREATE INDEX CONCURRENTLY ginidx ON tbl USING gin(j);
5760
SELECT bt_index_check('idx',true);
61+
SELECT gin_index_check('ginidx');
5862
SELECT pg_advisory_unlock(42);
5963
\endif
6064
)

‎contrib/amcheck/t/003_cic_2pc.pl

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'lock_timeout =' . (1000 *$PostgreSQL::Test::Utils::timeout_default));
2626
$node->start;
2727
$node->safe_psql('postgres',q(CREATE EXTENSION amcheck));
28-
$node->safe_psql('postgres',q(CREATE TABLE tbl(i int)));
28+
$node->safe_psql('postgres',q(CREATE TABLE tbl(i int, j jsonb)));
2929

3030

3131
#
@@ -41,7 +41,7 @@
4141
$main_h->query_safe(
4242
q(
4343
BEGIN;
44-
INSERT INTO tbl VALUES(0);
44+
INSERT INTO tbl VALUES(0, '[[14,2,3]]');
4545
));
4646

4747
my$cic_h =$node->background_psql('postgres');
@@ -50,6 +50,7 @@
5050
qr/start/,q(
5151
\echo start
5252
CREATE INDEX CONCURRENTLY idx ON tbl(i);
53+
CREATE INDEX CONCURRENTLY ginidx ON tbl USING gin(j);
5354
));
5455

5556
$main_h->query_safe(
@@ -60,7 +61,7 @@
6061
$main_h->query_safe(
6162
q(
6263
BEGIN;
63-
INSERT INTO tbl VALUES(0);
64+
INSERT INTO tbl VALUES(0, '[[14,2,3]]');
6465
));
6566

6667
$node->safe_psql('postgres',q(COMMIT PREPARED 'a';));
@@ -69,7 +70,7 @@
6970
q(
7071
PREPARE TRANSACTION 'b';
7172
BEGIN;
72-
INSERT INTO tbl VALUES(0);
73+
INSERT INTO tbl VALUES(0, '"mary had a little lamb"');
7374
));
7475

7576
$node->safe_psql('postgres',q(COMMIT PREPARED 'b';));
@@ -86,6 +87,9 @@
8687
$result =$node->psql('postgres',q(SELECT bt_index_check('idx',true)));
8788
is($result,'0','bt_index_check after overlapping 2PC');
8889

90+
$result =$node->psql('postgres',q(SELECT gin_index_check('ginidx')));
91+
is($result,'0','gin_index_check after overlapping 2PC');
92+
8993

9094
#
9195
# Server restart shall not change whether prepared xact blocks CIC
@@ -94,7 +98,7 @@
9498
$node->safe_psql(
9599
'postgres',q(
96100
BEGIN;
97-
INSERT INTO tbl VALUES(0);
101+
INSERT INTO tbl VALUES(0, '{"a":[["b",{"x":1}],["b",{"x":2}]],"c":3}');
98102
PREPARE TRANSACTION 'spans_restart';
99103
BEGIN;
100104
CREATE TABLE unused ();
@@ -108,12 +112,16 @@
108112
\echo start
109113
DROP INDEX CONCURRENTLY idx;
110114
CREATE INDEX CONCURRENTLY idx ON tbl(i);
115+
DROP INDEX CONCURRENTLY ginidx;
116+
CREATE INDEX CONCURRENTLY ginidx ON tbl USING gin(j);
111117
));
112118

113119
$node->safe_psql('postgres',"COMMIT PREPARED 'spans_restart'");
114120
$reindex_h->quit;
115121
$result =$node->psql('postgres',q(SELECT bt_index_check('idx',true)));
116122
is($result,'0','bt_index_check after 2PC and restart');
123+
$result =$node->psql('postgres',q(SELECT gin_index_check('ginidx')));
124+
is($result,'0','gin_index_check after 2PC and restart');
117125

118126

119127
#
@@ -136,14 +144,14 @@
136144
{
137145
'003_pgbench_concurrent_2pc'=>q(
138146
BEGIN;
139-
INSERT INTO tbl VALUES(0);
147+
INSERT INTO tbl VALUES(0,'null');
140148
PREPARE TRANSACTION 'c:client_id';
141149
COMMIT PREPARED 'c:client_id';
142150
),
143151
'003_pgbench_concurrent_2pc_savepoint'=>q(
144152
BEGIN;
145153
SAVEPOINT s1;
146-
INSERT INTO tbl VALUES(0);
154+
INSERT INTO tbl VALUES(0,'[false, "jnvaba", -76, 7, {"_": [1]}, 9]');
147155
PREPARE TRANSACTION 'c:client_id';
148156
COMMIT PREPARED 'c:client_id';
149157
),
@@ -163,7 +171,25 @@
163171
SELECT bt_index_check('idx',true);
164172
SELECT pg_advisory_unlock(42);
165173
\endif
174+
),
175+
'005_pgbench_concurrent_cic'=>q(
176+
SELECT pg_try_advisory_lock(42)::integer AS gotginlock \gset
177+
\if :gotginlock
178+
DROP INDEX CONCURRENTLY ginidx;
179+
CREATE INDEX CONCURRENTLY ginidx ON tbl USING gin(j);
180+
SELECT gin_index_check('ginidx');
181+
SELECT pg_advisory_unlock(42);
182+
\endif
183+
),
184+
'006_pgbench_concurrent_ric'=>q(
185+
SELECT pg_try_advisory_lock(42)::integer AS gotginlock \gset
186+
\if :gotginlock
187+
REINDEX INDEX CONCURRENTLY ginidx;
188+
SELECT gin_index_check('ginidx');
189+
SELECT pg_advisory_unlock(42);
190+
\endif
166191
)
192+
167193
});
168194

169195
$node->stop;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp