Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ DECLARE

-- There should now only be one active statement, following the abort of session
-- 1's transaction. The active statement is contributed by session 2.
1<: <... completed>
ERROR: canceling statement due to user request
0:SELECT rsqcountlimit, rsqcountvalue FROM pg_resqueue_status WHERE rsqname = 'rq_multi_portal';
rsqcountlimit | rsqcountvalue
---------------+---------------
Expand All @@ -162,8 +164,6 @@ DECLARE
(1 row)

-- After ending the transactions, there should be 0 active statements.
1<: <... completed>
ERROR: canceling statement due to user request
1:END;
END
2:END;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@

-- There should now only be one active statement, following the abort of session
-- 1's transaction. The active statement is contributed by session 2.
1<:
0:SELECT rsqcountlimit, rsqcountvalue FROM pg_resqueue_status WHERE rsqname = 'rq_multi_portal';
0:SELECT query, state from pg_stat_activity
WHERE query = 'DECLARE c2 CURSOR FOR SELECT 1;';

-- After ending the transactions, there should be 0 active statements.
1<:
1:END;
2:END;
0:SELECT rsqcountlimit, rsqcountvalue FROM pg_resqueue_status WHERE rsqname = 'rq_multi_portal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,5 @@ DROP TABLE tblspc_otherloc_heap;
DROP TABLESPACE testspace_otherloc;
CREATE TABLESPACE testspace_dir_empty LOCATION :'testtablespace';
CREATE TABLE t_dir_empty(a int);
\! rm -rf $PG_ABS_SRCDIR/testtablespace
DROP TABLE IF EXISTS t_dir_empty;
DROP TABLESPACE testspace_dir_empty;
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ CREATE FUNCTION recreate_two_level_table() RETURNS VOID
);
$fn$;
-- validate that there are no constraints when we start
SELECT * FROM partition_tables_show_all('r');
-- call partition_tables() directly: inside partition_tables_show_all() the
-- error depends on the join order picked by the planner
SELECT * FROM partition_tables('r');
ERROR: relation "r" does not exist
CONTEXT: SQL function "partition_tables" statement 1
SQL function "partition_tables_show_all" statement 1
-- UNIQUE constraint: validate we correctly add it and can only drop from root
SELECT recreate_two_level_table();
NOTICE: table "r" does not exist, skipping
Expand Down Expand Up @@ -872,10 +873,11 @@ CREATE FUNCTION recreate_three_level_table() RETURNS VOID
);
$fn$;
-- validate that there are no constraints when we start
SELECT * FROM partition_tables_show_all('r');
-- call partition_tables() directly: inside partition_tables_show_all() the
-- error depends on the join order picked by the planner
SELECT * FROM partition_tables('r');
ERROR: relation "r" does not exist
CONTEXT: SQL function "partition_tables" statement 1
SQL function "partition_tables_show_all" statement 1
-- UNIQUE constraint: validate we correctly add it and can only drop from root
SELECT recreate_three_level_table();
NOTICE: table "r" does not exist, skipping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ select gp_segment_id, pg_reload_conf() from gp_id union select gp_segment_id, pg
-- The reason for restarting cbdb here is that if the subsequent
-- vacuum ao test(uao*_catalog_tables/threshold) encounters an
-- unfinished transaction, it will fail.
--\!gpstop -ari
\!gpstop -ar
-- end_ignore
1 change: 0 additions & 1 deletion contrib/pax_storage/src/test/regress/sql/gp_tablespace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ DROP TABLESPACE testspace_otherloc;

CREATE TABLESPACE testspace_dir_empty LOCATION :'testtablespace';
CREATE TABLE t_dir_empty(a int);
\! rm -rf $PG_ABS_SRCDIR/testtablespace
DROP TABLE IF EXISTS t_dir_empty;
DROP TABLESPACE testspace_dir_empty;

Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ CREATE FUNCTION recreate_two_level_table() RETURNS VOID
$fn$;

-- validate that there are no constraints when we start
SELECT * FROM partition_tables_show_all('r');
-- call partition_tables() directly: inside partition_tables_show_all() the
-- error depends on the join order picked by the planner
SELECT * FROM partition_tables('r');

-- UNIQUE constraint: validate we correctly add it and can only drop from root
SELECT recreate_two_level_table();
Expand Down Expand Up @@ -331,7 +333,9 @@ CREATE FUNCTION recreate_three_level_table() RETURNS VOID
$fn$;

-- validate that there are no constraints when we start
SELECT * FROM partition_tables_show_all('r');
-- call partition_tables() directly: inside partition_tables_show_all() the
-- error depends on the join order picked by the planner
SELECT * FROM partition_tables('r');

-- UNIQUE constraint: validate we correctly add it and can only drop from root
SELECT recreate_three_level_table();
Expand Down
20 changes: 20 additions & 0 deletions gpcontrib/gp_toolkit/expected/gp_toolkit.out
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,26 @@ from gp_toolkit.gp_bloat_diag where bdirelid = 'toolkit_skew'::regclass;
toolkit_skew | public | toolkit_skew | t | t | f | t | significant amount of bloat suspected
(1 row)

-- Vacuum can only remove the deleted rows, and so truncate the table, if no
-- other backend holds a snapshot older than the delete, e.g. an auto-analyze
-- started after the cluster restart in the previous test. Wait for those to
-- finish. Plain autovacuum VACUUMs do not hold back the horizon.
DO $$
BEGIN
FOR i in 1..600 loop
IF NOT EXISTS (SELECT 1 FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
AND (backend_xmin IS NOT NULL OR backend_xid IS NOT NULL)
AND NOT (backend_type = 'autovacuum worker'
AND query LIKE 'autovacuum: VACUUM %'
AND query NOT LIKE '%ANALYZE%')) THEN
RETURN;
END IF;
PERFORM pg_sleep(0.1);
PERFORM pg_stat_clear_snapshot();
END LOOP;
raise notice 'other backends still hold a snapshot';
END$$;
-- After vacuum, bloat should be gone
vacuum toolkit_skew;
select btdrelpages > 0 as btdrelpages_over_0,
Expand Down
2 changes: 1 addition & 1 deletion gpcontrib/gp_toolkit/gp_toolkit--1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ CREATE EXTERNAL WEB TABLE gp_toolkit.__gp_log_master_ext
logstack text
)
EXECUTE E'cat $GP_SEG_DATADIR/log/*.csv' ON COORDINATOR
FORMAT 'CSV' (DELIMITER AS ',' NULL AS '' QUOTE AS '"');
FORMAT 'CSV' (DELIMITER AS ',' NULL AS '' QUOTE AS '"' ESCAPE AS '\');

REVOKE ALL ON TABLE gp_toolkit.__gp_log_master_ext FROM public;

Expand Down
20 changes: 20 additions & 0 deletions gpcontrib/gp_toolkit/sql/gp_toolkit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ select bdirelid::regclass, bdinspname, bdirelname,
bdidiag
from gp_toolkit.gp_bloat_diag where bdirelid = 'toolkit_skew'::regclass;

-- Vacuum can only remove the deleted rows, and so truncate the table, if no
-- other backend holds a snapshot older than the delete, e.g. an auto-analyze
-- started after the cluster restart in the previous test. Wait for those to
-- finish. Plain autovacuum VACUUMs do not hold back the horizon.
DO $$
BEGIN
FOR i in 1..600 loop
IF NOT EXISTS (SELECT 1 FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
AND (backend_xmin IS NOT NULL OR backend_xid IS NOT NULL)
AND NOT (backend_type = 'autovacuum worker'
AND query LIKE 'autovacuum: VACUUM %'
AND query NOT LIKE '%ANALYZE%')) THEN
RETURN;
END IF;
PERFORM pg_sleep(0.1);
PERFORM pg_stat_clear_snapshot();
END LOOP;
raise notice 'other backends still hold a snapshot';
END$$;
-- After vacuum, bloat should be gone
vacuum toolkit_skew;
select btdrelpages > 0 as btdrelpages_over_0,
Expand Down
42 changes: 8 additions & 34 deletions src/backend/catalog/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2162,40 +2162,14 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
/* Unset this so no one tries to look up the generation expression */
attStruct->attgenerated = '\0';

/* Update distribution policy for dropped distribution column */
if (GpPolicyIsHashPartitioned(rel->rd_cdbpolicy))
{
int ia = 0;

for (ia = 0; ia < rel->rd_cdbpolicy->nattrs; ia++)
{
if (attnum == rel->rd_cdbpolicy->attrs[ia])
{
MemoryContext oldcontext;
GpPolicy *policy;

/* force a random distribution */
rel->rd_cdbpolicy->nattrs = 0;

oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(rel));
policy = GpPolicyCopy(rel->rd_cdbpolicy);
MemoryContextSwitchTo(oldcontext);

/*
* replace policy first in catalog and then assign to
* rd_cdbpolicy to make sure we have intended policy in relcache
* even with relcache invalidation. Otherwise rd_cdbpolicy can
* become invalid soon after assignment.
*/
GpPolicyReplace(RelationGetRelid(rel), policy);
rel->rd_cdbpolicy = policy;
if (Gp_role != GP_ROLE_EXECUTE)
ereport(NOTICE,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("dropping a column that is part of the distribution policy forces a random distribution policy")));
}
}
}
/*
* The distribution policy was already switched to random by
* set_random_distribution_if_drop_distkey() above. Don't consult
* rel->rd_cdbpolicy again here: a relcache rebuild in between (e.g.
* after a sinval reset) reloads the not-yet-visible old policy, and
* a second GpPolicyReplace() on the same gp_distribution_policy row
* fails with "tuple already updated by self".
*/

/*
* Change the column name to something that isn't likely to conflict
Expand Down
8 changes: 8 additions & 0 deletions src/test/isolation2/expected/bitmap_index_crash.out
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ ALTER
--------
OK
(1 row)
-- pg_ctl -w returns once crash recovery has started, not when seg1 accepts
-- connections again. Gang creation retries while the segment is in recovery,
-- so dispatch to it from a new session before connecting directly below.
3:SELECT count(*) FROM bm;
count
-------
5000
(1 row)
3:SELECT gp_inject_fault_infinite('checkpoint', 'reset', dbid) FROM gp_segment_configuration WHERE role='p';
gp_inject_fault_infinite
--------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/test/isolation2/expected/orphan_temp_table.out
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ BEGIN
(0 rows)
2q: ... <quitting>

-- 2q only closes the connection; the backend drops its temp objects on
-- exit asynchronously, so wait for that to finish (up to 60s).
3: do $$ begin for i in 1..600 loop if (select count(*) from pg_class where relname = 'test_temp_table_cleanup') = 0 then return; end if; perform pg_sleep(0.1); end loop; end $$;
DO
3: select count(*) from pg_class where relname = 'test_temp_table_cleanup';
count
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
!\retcode gpstop -rai;
(exited with code 0)

-- make sure the mirror is in sync, otherwise FTS will not promote it below
1: select wait_until_segment_synchronized(0);
wait_until_segment_synchronized
---------------------------------
OK
(1 row)
1: create extension if not exists gp_inject_fault;
CREATE
1: create table t_rename1 (a int);
Expand Down
Loading
Loading