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

Commit 0811f76

Browse files
committed
pg_surgery: Try to stabilize regression tests.
According to buildfarm member sungazer, the behavior of VACUUM can be unstable in these tests even if we prevent autovacuum from running on the tables in question, apparently because even a manual vacuum can behave differently depending on whether anything else is running that holds back the global xmin. So use a temporary table instead, which as of commit a7212be enables vacuuming using a more aggressive cutoff. This approach can't be used for the regression test that involves a materialized view, but that test doesn't run vacuum, so it shouldn't be prone to this particular failure mode. Analysis by Tom Lane. Patch by Ashutosh Sharma and me. Discussion: http://postgr.es/m/665524.1599948007@sss.pgh.pa.us
1 parent 24fb35e commit 0811f76

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

contrib/pg_surgery/expected/heap_surgery.out

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
create extension pg_surgery;
22
-- create a normal heap table and insert some rows.
3-
-- note that we don't commit the transaction, so autovacuum can't interfere.
4-
begin;
5-
create table htab(a int);
3+
-- use a temp table so that vacuum behavior doesn't depend on global xmin
4+
create temp table htab (a int);
65
insert into htab values (100), (200), (300), (400), (500);
76
-- test empty TID array
87
select heap_force_freeze('htab'::regclass, ARRAY[]::tid[]);
@@ -85,9 +84,9 @@ NOTICE: skipping tid (0, 6) for relation "htab" because the item number is out
8584

8685
(1 row)
8786

88-
rollback;
8987
-- set up a new table with a redirected line pointer
90-
create table htab2(a int) with (autovacuum_enabled = off);
88+
-- use a temp table so that vacuum behavior doesn't depend on global xmin
89+
create temp table htab2(a int);
9190
insert into htab2 values (100);
9291
update htab2 set a = 200;
9392
vacuum htab2;
@@ -175,6 +174,5 @@ ERROR: "vw" is not a table, materialized view, or TOAST table
175174
select heap_force_freeze('vw'::regclass, ARRAY['(0, 1)']::tid[]);
176175
ERROR: "vw" is not a table, materialized view, or TOAST table
177176
-- cleanup.
178-
drop table htab2;
179177
drop view vw;
180178
drop extension pg_surgery;

contrib/pg_surgery/sql/heap_surgery.sql

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
create extension pg_surgery;
22

33
-- create a normal heap table and insert some rows.
4-
-- note that we don't commit the transaction, so autovacuum can't interfere.
5-
begin;
6-
create table htab(a int);
4+
-- use a temp table so that vacuum behavior doesn't depend on global xmin
5+
create temp table htab (a int);
76
insert into htab values (100), (200), (300), (400), (500);
87

98
-- test empty TID array
@@ -38,10 +37,9 @@ select ctid, xmax from htab where xmin = 2;
3837
-- out-of-range TIDs should be skipped
3938
select heap_force_freeze('htab'::regclass, ARRAY['(0, 0)', '(0, 6)']::tid[]);
4039

41-
rollback;
42-
4340
-- set up a new table with a redirected line pointer
44-
create table htab2(a int) with (autovacuum_enabled = off);
41+
-- use a temp table so that vacuum behavior doesn't depend on global xmin
42+
create temp table htab2(a int);
4543
insert into htab2 values (100);
4644
update htab2 set a = 200;
4745
vacuum htab2;
@@ -86,6 +84,5 @@ select heap_force_kill('vw'::regclass, ARRAY['(0, 1)']::tid[]);
8684
select heap_force_freeze('vw'::regclass, ARRAY['(0, 1)']::tid[]);
8785

8886
-- cleanup.
89-
drop table htab2;
9087
drop view vw;
9188
drop extension pg_surgery;

0 commit comments

Comments
 (0)