Commit 0811f766 authored by Robert Haas's avatar Robert Haas

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 a7212be8 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
parent 24fb35e1
create extension pg_surgery; create extension pg_surgery;
-- create a normal heap table and insert some rows. -- create a normal heap table and insert some rows.
-- note that we don't commit the transaction, so autovacuum can't interfere. -- use a temp table so that vacuum behavior doesn't depend on global xmin
begin; create temp table htab (a int);
create table htab(a int);
insert into htab values (100), (200), (300), (400), (500); insert into htab values (100), (200), (300), (400), (500);
-- test empty TID array -- test empty TID array
select heap_force_freeze('htab'::regclass, ARRAY[]::tid[]); 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 ...@@ -85,9 +84,9 @@ NOTICE: skipping tid (0, 6) for relation "htab" because the item number is out
(1 row) (1 row)
rollback;
-- set up a new table with a redirected line pointer -- set up a new table with a redirected line pointer
create table htab2(a int) with (autovacuum_enabled = off); -- use a temp table so that vacuum behavior doesn't depend on global xmin
create temp table htab2(a int);
insert into htab2 values (100); insert into htab2 values (100);
update htab2 set a = 200; update htab2 set a = 200;
vacuum htab2; vacuum htab2;
...@@ -175,6 +174,5 @@ ERROR: "vw" is not a table, materialized view, or TOAST table ...@@ -175,6 +174,5 @@ ERROR: "vw" is not a table, materialized view, or TOAST table
select heap_force_freeze('vw'::regclass, ARRAY['(0, 1)']::tid[]); select heap_force_freeze('vw'::regclass, ARRAY['(0, 1)']::tid[]);
ERROR: "vw" is not a table, materialized view, or TOAST table ERROR: "vw" is not a table, materialized view, or TOAST table
-- cleanup. -- cleanup.
drop table htab2;
drop view vw; drop view vw;
drop extension pg_surgery; drop extension pg_surgery;
create extension pg_surgery; create extension pg_surgery;
-- create a normal heap table and insert some rows. -- create a normal heap table and insert some rows.
-- note that we don't commit the transaction, so autovacuum can't interfere. -- use a temp table so that vacuum behavior doesn't depend on global xmin
begin; create temp table htab (a int);
create table htab(a int);
insert into htab values (100), (200), (300), (400), (500); insert into htab values (100), (200), (300), (400), (500);
-- test empty TID array -- test empty TID array
...@@ -38,10 +37,9 @@ select ctid, xmax from htab where xmin = 2; ...@@ -38,10 +37,9 @@ select ctid, xmax from htab where xmin = 2;
-- out-of-range TIDs should be skipped -- out-of-range TIDs should be skipped
select heap_force_freeze('htab'::regclass, ARRAY['(0, 0)', '(0, 6)']::tid[]); select heap_force_freeze('htab'::regclass, ARRAY['(0, 0)', '(0, 6)']::tid[]);
rollback;
-- set up a new table with a redirected line pointer -- set up a new table with a redirected line pointer
create table htab2(a int) with (autovacuum_enabled = off); -- use a temp table so that vacuum behavior doesn't depend on global xmin
create temp table htab2(a int);
insert into htab2 values (100); insert into htab2 values (100);
update htab2 set a = 200; update htab2 set a = 200;
vacuum htab2; vacuum htab2;
...@@ -86,6 +84,5 @@ select heap_force_kill('vw'::regclass, ARRAY['(0, 1)']::tid[]); ...@@ -86,6 +84,5 @@ select heap_force_kill('vw'::regclass, ARRAY['(0, 1)']::tid[]);
select heap_force_freeze('vw'::regclass, ARRAY['(0, 1)']::tid[]); select heap_force_freeze('vw'::regclass, ARRAY['(0, 1)']::tid[]);
-- cleanup. -- cleanup.
drop table htab2;
drop view vw; drop view vw;
drop extension pg_surgery; drop extension pg_surgery;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment