Skip to content

Commit ae372e6

Browse files
committed
Re-add BRIN isolation test
This time, instead of using a core isolation test, put it on its own test module; this way it can require the pageinspect module to be present before running. The module's Makefile is loosely modeled after test_decoding's, so that it's easy to add further tests for either pg_regress or isolationtester later. Backpatch to 9.5.
1 parent 657cdb3 commit ae372e6

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed

src/test/modules/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ top_builddir = ../../..
55
include $(top_builddir)/src/Makefile.global
66

77
SUBDIRS = \
8+
brin \
89
commit_ts \
910
dummy_seclabel \
1011
test_ddl_deparse \

src/test/modules/brin/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Generated subdirectories
2+
/isolation_output/
3+
/tmp_check/

src/test/modules/brin/Makefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# src/test/modules/brin/Makefile
2+
3+
EXTRA_CLEAN = ./isolation_output
4+
EXTRA_INSTALL=contrib/pageinspect
5+
6+
ISOLATIONCHECKS=summarization-and-inprogress-insertion
7+
8+
ifdef USE_PGXS
9+
PG_CONFIG = pg_config
10+
PGXS := $(shell $(PG_CONFIG) --pgxs)
11+
include $(PGXS)
12+
else
13+
subdir = src/test/modules/brin
14+
top_builddir = ../../../..
15+
include $(top_builddir)/src/Makefile.global
16+
include $(top_srcdir)/contrib/contrib-global.mk
17+
endif
18+
19+
check: isolation-check
20+
21+
isolation-check: | submake-isolation
22+
$(MKDIR_P) isolation_output
23+
$(pg_isolation_regress_check) \
24+
--outputdir=./isolation_output \
25+
$(ISOLATIONCHECKS)
26+
27+
PHONY: check isolation-check
28+
29+
submake-isolation:
30+
$(MAKE) -C $(top_builddir)/src/test/isolation all
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: s2check s1b s2b s1i s2summ s1c s2c s2check
4+
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
5+
itemoffset blknum attnum allnulls hasnulls placeholder value
6+
7+
1 0 1 f f f {1 .. 1}
8+
step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
9+
step s2b: BEGIN ISOLATION LEVEL REPEATABLE READ; SELECT 1;
10+
?column?
11+
12+
1
13+
step s1i: INSERT INTO brin_iso VALUES (1000);
14+
step s2summ: SELECT brin_summarize_new_values('brinidx'::regclass);
15+
brin_summarize_new_values
16+
17+
1
18+
step s1c: COMMIT;
19+
step s2c: COMMIT;
20+
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
21+
itemoffset blknum attnum allnulls hasnulls placeholder value
22+
23+
1 0 1 f f f {1 .. 1}
24+
2 1 1 f f f {1 .. 1000}
25+
26+
starting permutation: s2check s1b s1i s2vacuum s1c s2check
27+
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
28+
itemoffset blknum attnum allnulls hasnulls placeholder value
29+
30+
1 0 1 f f f {1 .. 1}
31+
step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
32+
step s1i: INSERT INTO brin_iso VALUES (1000);
33+
step s2vacuum: VACUUM brin_iso;
34+
step s1c: COMMIT;
35+
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
36+
itemoffset blknum attnum allnulls hasnulls placeholder value
37+
38+
1 0 1 f f f {1 .. 1}
39+
2 1 1 f f f {1 .. 1000}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This test verifies that values inserted in transactions still in progress
2+
# are considered during concurrent range summarization (either using the
3+
# brin_summarize_new_values function or regular VACUUM).
4+
5+
setup
6+
{
7+
CREATE TABLE brin_iso (
8+
value int
9+
) WITH (fillfactor=10);
10+
CREATE INDEX brinidx ON brin_iso USING brin (value) WITH (pages_per_range=1);
11+
-- this fills the first page
12+
DO $$
13+
DECLARE curtid tid;
14+
BEGIN
15+
LOOP
16+
INSERT INTO brin_iso VALUES (1) RETURNING ctid INTO curtid;
17+
EXIT WHEN curtid > tid '(1, 0)';
18+
END LOOP;
19+
END;
20+
$$;
21+
CREATE EXTENSION IF NOT EXISTS pageinspect;
22+
}
23+
24+
teardown
25+
{
26+
DROP TABLE brin_iso;
27+
}
28+
29+
session "s1"
30+
step "s1b" { BEGIN ISOLATION LEVEL REPEATABLE READ; }
31+
step "s1i" { INSERT INTO brin_iso VALUES (1000); }
32+
step "s1c" { COMMIT; }
33+
34+
session "s2"
35+
step "s2b" { BEGIN ISOLATION LEVEL REPEATABLE READ; SELECT 1; }
36+
step "s2summ" { SELECT brin_summarize_new_values('brinidx'::regclass); }
37+
step "s2c" { COMMIT; }
38+
39+
step "s2vacuum" { VACUUM brin_iso; }
40+
41+
step "s2check" { SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass); }
42+
43+
permutation "s2check" "s1b" "s2b" "s1i" "s2summ" "s1c" "s2c" "s2check"
44+
permutation "s2check" "s1b" "s1i" "s2vacuum" "s1c" "s2check"

0 commit comments

Comments
 (0)