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

Commit c2dc1a7

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 6b4d304 commit c2dc1a7

File tree

7 files changed

+15
-31
lines changed

7 files changed

+15
-31
lines changed

contrib/amcheck/expected/check_heap.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ ERROR: ending block number must be between 0 and 0
109109
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 10000, endblock := 11000);
110110
ERROR: starting block number must be between 0 and 0
111111
-- Vacuum freeze to change the xids encountered in subsequent tests
112-
VACUUM FREEZE heaptest;
112+
VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) heaptest;
113113
-- Check that valid options are not rejected nor corruption reported
114114
-- for a non-empty frozen table
115115
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'none');

contrib/amcheck/sql/check_heap.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock :=
5151
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 10000, endblock := 11000);
5252

5353
-- Vacuum freeze to change the xids encountered in subsequent tests
54-
VACUUM FREEZE heaptest;
54+
VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) heaptest;
5555

5656
-- Check that valid options are not rejected nor corruption reported
5757
-- for a non-empty frozen table

contrib/amcheck/t/001_verify_heapam.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# Check a corrupt table with all-frozen data
4747
#
4848
fresh_test_table('test');
49-
$node->safe_psql('postgres', q(VACUUM FREEZE test));
49+
$node->safe_psql('postgres', q(VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test));
5050
corrupt_first_page('test');
5151
detects_heap_corruption("verify_heapam('test')",
5252
"all-frozen corrupted table");

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;
@@ -87,18 +87,8 @@ SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
8787
(1 row)
8888

8989
-- If we freeze the only tuple on test1, the infomask should
90-
-- always be the same in all test runs. we show raw flags by
91-
-- default: HEAP_XMIN_COMMITTED and HEAP_XMIN_INVALID.
92-
VACUUM FREEZE test1;
93-
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
94-
FROM heap_page_items(get_raw_page('test1', 0)),
95-
LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);
96-
t_infomask | t_infomask2 | raw_flags | combined_flags
97-
------------+-------------+-----------------------------------------------------------+--------------------
98-
2816 | 2 | {HEAP_XMIN_COMMITTED,HEAP_XMIN_INVALID,HEAP_XMAX_INVALID} | {HEAP_XMIN_FROZEN}
99-
(1 row)
100-
101-
-- output the decoded flag HEAP_XMIN_FROZEN instead
90+
-- always be the same in all test runs.
91+
VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test1;
10292
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
10393
FROM heap_page_items(get_raw_page('test1', 0)),
10494
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.
@@ -34,15 +34,9 @@ SELECT tuple_data_split('test1'::regclass, t_data, t_infomask, t_infomask2, t_bi
3434
SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
3535

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

41-
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
42-
FROM heap_page_items(get_raw_page('test1', 0)),
43-
LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);
44-
45-
-- output the decoded flag HEAP_XMIN_FROZEN instead
4640
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
4741
FROM heap_page_items(get_raw_page('test1', 0)),
4842
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
@@ -105,7 +105,7 @@ ERROR: "test_foreign_table" is not a table, materialized view, or TOAST table
105105
create table regular_table (a int, b text);
106106
alter table regular_table alter column b set storage external;
107107
insert into regular_table values (1, repeat('one', 1000)), (2, repeat('two', 1000));
108-
vacuum regular_table;
108+
vacuum (disable_page_skipping) regular_table;
109109
select count(*) > 0 from pg_visibility('regular_table');
110110
?column?
111111
----------
@@ -132,7 +132,7 @@ select count(*) > 0 from pg_visibility((select reltoastrelid from pg_class where
132132
(1 row)
133133

134134
create materialized view matview_visibility_test as select * from regular_table;
135-
vacuum matview_visibility_test;
135+
vacuum (disable_page_skipping) matview_visibility_test;
136136
select count(*) > 0 from pg_visibility('matview_visibility_test');
137137
?column?
138138
----------
@@ -149,7 +149,7 @@ select count(*) > 0 from pg_visibility('matview_visibility_test');
149149

150150
-- regular tables which are part of a partition *do* have visibility maps
151151
insert into test_partition values (1);
152-
vacuum test_partition;
152+
vacuum (disable_page_skipping) test_partition;
153153
select count(*) > 0 from pg_visibility('test_partition', 0);
154154
?column?
155155
----------

contrib/pg_visibility/sql/pg_visibility.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,23 @@ select pg_truncate_visibility_map('test_foreign_table');
7171
create table regular_table (a int, b text);
7272
alter table regular_table alter column b set storage external;
7373
insert into regular_table values (1, repeat('one', 1000)), (2, repeat('two', 1000));
74-
vacuum regular_table;
74+
vacuum (disable_page_skipping) regular_table;
7575
select count(*) > 0 from pg_visibility('regular_table');
7676
select count(*) > 0 from pg_visibility((select reltoastrelid from pg_class where relname = 'regular_table'));
7777
truncate regular_table;
7878
select count(*) > 0 from pg_visibility('regular_table');
7979
select count(*) > 0 from pg_visibility((select reltoastrelid from pg_class where relname = 'regular_table'));
8080

8181
create materialized view matview_visibility_test as select * from regular_table;
82-
vacuum matview_visibility_test;
82+
vacuum (disable_page_skipping) matview_visibility_test;
8383
select count(*) > 0 from pg_visibility('matview_visibility_test');
8484
insert into regular_table values (1), (2);
8585
refresh materialized view matview_visibility_test;
8686
select count(*) > 0 from pg_visibility('matview_visibility_test');
8787

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

0 commit comments

Comments
 (0)