Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a57dbfc

Browse files
committed
Disable vacuum page skipping in selected test cases.
By default VACUUM will skip pages that it can't immediately get exclusive access to, which means that even activities as harmless and unpredictable as checkpoint buffer writes might prevent a page from being processed. Ordinarily this is no big deal, but we have a small number of test cases that examine the results of VACUUM's processing and therefore will fail if the page of interest is skipped. This seems to be the explanation for some rare buildfarm failures. To fix, add the DISABLE_PAGE_SKIPPING option to the VACUUM commands in tests where this could be an issue. In passing, remove a duplicated query in pageinspect/sql/page.sql. Back-patch as necessary (some of these cases are as old as v10). Discussion: https://postgr.es/m/413923.1611006484@sss.pgh.pa.us
1 parent b8403d1 commit a57dbfc

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

contrib/pageinspect/expected/page.out

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CREATE EXTENSION pageinspect;
22
CREATE TABLE test1 (a int, b int);
33
INSERT INTO test1 VALUES (16777217, 131584);
4-
VACUUM test1; -- set up FSM
4+
VACUUM (DISABLE_PAGE_SKIPPING) test1; -- set up FSM
55
-- The page contents can vary, so just test that it can be read
66
-- successfully, but don't keep the output.
77
SELECT octet_length(get_raw_page('test1', 'main', 0)) AS main_0;
@@ -83,18 +83,8 @@ SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
8383
(1 row)
8484

8585
-- If we freeze the only tuple on test1, the infomask should
86-
-- always be the same in all test runs. we show raw flags by
87-
-- default: HEAP_XMIN_COMMITTED and HEAP_XMIN_INVALID.
88-
VACUUM FREEZE test1;
89-
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
90-
FROM heap_page_items(get_raw_page('test1', 0)),
91-
LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);
92-
t_infomask | t_infomask2 | raw_flags | combined_flags
93-
------------+-------------+-----------------------------------------------------------+--------------------
94-
2816 | 2 | {HEAP_XMIN_COMMITTED,HEAP_XMIN_INVALID,HEAP_XMAX_INVALID} | {HEAP_XMIN_FROZEN}
95-
(1 row)
96-
97-
-- output the decoded flag HEAP_XMIN_FROZEN instead
86+
-- always be the same in all test runs.
87+
VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test1;
9888
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
9989
FROM heap_page_items(get_raw_page('test1', 0)),
10090
LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);

contrib/pageinspect/sql/page.sql

+3-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CREATE EXTENSION pageinspect;
33
CREATE TABLE test1 (a int, b int);
44
INSERT INTO test1 VALUES (16777217, 131584);
55

6-
VACUUM test1; -- set up FSM
6+
VACUUM (DISABLE_PAGE_SKIPPING) test1; -- set up FSM
77

88
-- The page contents can vary, so just test that it can be read
99
-- successfully, but don't keep the output.
@@ -32,15 +32,9 @@ SELECT tuple_data_split('test1'::regclass, t_data, t_infomask, t_infomask2, t_bi
3232
SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
3333

3434
-- If we freeze the only tuple on test1, the infomask should
35-
-- always be the same in all test runs. we show raw flags by
36-
-- default: HEAP_XMIN_COMMITTED and HEAP_XMIN_INVALID.
37-
VACUUM FREEZE test1;
35+
-- always be the same in all test runs.
36+
VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test1;
3837

39-
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
40-
FROM heap_page_items(get_raw_page('test1', 0)),
41-
LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);
42-
43-
-- output the decoded flag HEAP_XMIN_FROZEN instead
4438
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
4539
FROM heap_page_items(get_raw_page('test1', 0)),
4640
LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);

contrib/pg_visibility/expected/pg_visibility.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ERROR: "test_foreign_table" is not a table, materialized view, or TOAST table
104104
-- check some of the allowed relkinds
105105
create table regular_table (a int);
106106
insert into regular_table values (1), (2);
107-
vacuum regular_table;
107+
vacuum (disable_page_skipping) regular_table;
108108
select count(*) > 0 from pg_visibility('regular_table');
109109
?column?
110110
----------
@@ -119,7 +119,7 @@ select count(*) > 0 from pg_visibility('regular_table');
119119
(1 row)
120120

121121
create materialized view matview_visibility_test as select * from regular_table;
122-
vacuum matview_visibility_test;
122+
vacuum (disable_page_skipping) matview_visibility_test;
123123
select count(*) > 0 from pg_visibility('matview_visibility_test');
124124
?column?
125125
----------
@@ -136,7 +136,7 @@ select count(*) > 0 from pg_visibility('matview_visibility_test');
136136

137137
-- regular tables which are part of a partition *do* have visibility maps
138138
insert into test_partition values (1);
139-
vacuum test_partition;
139+
vacuum (disable_page_skipping) test_partition;
140140
select count(*) > 0 from pg_visibility('test_partition', 0);
141141
?column?
142142
----------

contrib/pg_visibility/sql/pg_visibility.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ select pg_truncate_visibility_map('test_foreign_table');
7070
-- check some of the allowed relkinds
7171
create table regular_table (a int);
7272
insert into regular_table values (1), (2);
73-
vacuum regular_table;
73+
vacuum (disable_page_skipping) regular_table;
7474
select count(*) > 0 from pg_visibility('regular_table');
7575
truncate regular_table;
7676
select count(*) > 0 from pg_visibility('regular_table');
7777

7878
create materialized view matview_visibility_test as select * from regular_table;
79-
vacuum matview_visibility_test;
79+
vacuum (disable_page_skipping) matview_visibility_test;
8080
select count(*) > 0 from pg_visibility('matview_visibility_test');
8181
insert into regular_table values (1), (2);
8282
refresh materialized view matview_visibility_test;
8383
select count(*) > 0 from pg_visibility('matview_visibility_test');
8484

8585
-- regular tables which are part of a partition *do* have visibility maps
8686
insert into test_partition values (1);
87-
vacuum test_partition;
87+
vacuum (disable_page_skipping) test_partition;
8888
select count(*) > 0 from pg_visibility('test_partition', 0);
8989
select count(*) > 0 from pg_visibility_map('test_partition');
9090
select count(*) > 0 from pg_visibility_map_summary('test_partition');

0 commit comments

Comments
 (0)