Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 179 additions & 107 deletions .github/workflows/pg16-merge-validation.yml

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/backend/utils/activity/pgstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,7 @@ assign_stats_fetch_consistency(int newval, void *extra)
void
pgstat_send_qd_tabstats(void)
{
int nest_level;
PgStat_SubXactStatus *xact_state;
StringInfoData buf;
PgStatTabRecordFromQE *records;
Expand All @@ -1788,10 +1789,14 @@ pgstat_send_qd_tabstats(void)
* current nesting level's per-table insert/update/delete counts.
*/
xact_state = pgstat_get_current_xact_stack();

if (xact_state == NULL)
return;

nest_level = GetCurrentTransactionNestLevel();

if (nest_level != xact_state->nest_level)
return;

records = (PgStatTabRecordFromQE *)
palloc(capacity * sizeof(PgStatTabRecordFromQE));

Expand Down
7 changes: 5 additions & 2 deletions src/bin/pg_basebackup/bbstreamer_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,15 @@ extract_directory(const char *filename, mode_t mode)
* pg_xlog we assume is deleted at the start of
* pg_basebackup. We cannot delete pg_xlog because if
* streammode was used then it may have already copied
* new xlog files into pg_xlog directory.
* new xlog files into pg_xlog directory. Similarly,
* archive_status may have .done files created by the
* WAL streamer child process via mark_file_as_archived().
*/
if (pg_str_endswith(filename, "/pg_log") ||
pg_str_endswith(filename, "/log") ||
pg_str_endswith(filename, "/pg_wal") ||
pg_str_endswith(filename, "/pg_xlog"))
pg_str_endswith(filename, "/pg_xlog") ||
pg_str_endswith(filename, "/archive_status"))
return;

rmtree(filename, true);
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test_parallel_retrieve_cursor_extended_query_error: test_parallel_retrieve_curso
$(CC) $(CPPFLAGS) $(rpath) -I$(top_builddir)/src/interfaces/libpq -L$(GPHOME)/lib -L$(top_builddir)/src/interfaces/libpq -o $@ $< -lpq

pg_regress.o:
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress.o
$(MAKE) -C $(top_builddir)/src/test/regress install
rm -f $@ && $(LN_S) $(top_builddir)/src/test/regress/pg_regress.o .

gpstringsubs.pl:
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/expected/bitmap_index_crash.out
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ select count(*) from test_bitmap where type = 520;
(1 row)

-- start_ignore
! gpstop -rai;
! gpstop -raf;
-- end_ignore

0: select count(*) from test_bitmap where type = 520;
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/expected/gdd/end.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ALTER
-- Use utility session on seg 0 to restart master. This way avoids the
-- situation where session issuing the restart doesn't disappear
-- itself.
1U:SELECT pg_ctl(dir, 'restart') from datadir;
1U:SELECT pg_ctl(dir, 'restart', 'fast') from datadir;
pg_ctl
--------
OK
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/expected/gdd/prepare.out
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ALTER
-- Use utility session on seg 0 to restart master. This way avoids the
-- situation where session issuing the restart doesn't disappear
-- itself.
1U:SELECT pg_ctl(dir, 'restart') from datadir;
1U:SELECT pg_ctl(dir, 'restart', 'fast') from datadir;
pg_ctl
--------
OK
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/expected/instr_in_shmem_setup.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-- start_ignore
! gpconfig -c gp_enable_query_metrics -v on; ! gpstop -rai;
! gpconfig -c gp_enable_query_metrics -v on; ! gpstop -raf;
-- end_ignore
32 changes: 29 additions & 3 deletions src/test/isolation2/expected/pg_rewind_fail_missing_xlog.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ INSERT 3

-- end_ignore
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
(exited with code 0)

-- Test 1: Ensure that pg_rewind doesn't fail due to checkpoints inadvertently
Expand Down Expand Up @@ -543,14 +543,40 @@ server closed the connection unexpectedly

-- end_ignore
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- start_ignore
-- end_ignore
(exited with code 0)

-- Create an unlogged table on the primary that remembers replication slot's last restart_lsn and number of WAL files.
1U: CREATE UNLOGGED TABLE unlogged_wal_retention_test(restart_lsn_before pg_lsn, wal_count_before int);
CREATE
-- Force WAL segment switches to ensure there are old WAL files that can be removed after checkpoint.
1U: SELECT pg_switch_wal() IS NOT NULL;
?column?
----------
t
(1 row)
1U: SELECT pg_switch_wal() IS NOT NULL;
?column?
----------
t
(1 row)
1U: SELECT pg_switch_wal() IS NOT NULL;
?column?
----------
t
(1 row)
1U: SELECT pg_switch_wal() IS NOT NULL;
?column?
----------
t
(1 row)
1U: SELECT pg_switch_wal() IS NOT NULL;
?column?
----------
t
(1 row)
1U: INSERT INTO unlogged_wal_retention_test SELECT (select restart_lsn FROM pg_replication_slots WHERE slot_name = 'internal_wal_replication_slot') as restart_lsn_before, (select count(*) from pg_ls_waldir()) as wal_count_before;
INSERT 1
5: CHECKPOINT;
Expand Down Expand Up @@ -663,7 +689,7 @@ DROP

-- end_ignore
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- start_ignore
-- end_ignore
(exited with code 0)
4 changes: 2 additions & 2 deletions src/test/isolation2/expected/prepare_limit.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-- Enable gp_autostats_mode to make sure the single value insert triger 2pc
!\retcode gpconfig -c gp_autostats_mode -v 'on_no_stats' --skipvalidation;
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
(exited with code 0)

5: create table prepare_limit1 (a int);
Expand Down Expand Up @@ -119,5 +119,5 @@ DROP
(exited with code 0)
!\retcode gpconfig -c gp_autostats_mode -v 'none' --skipvalidation;
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
(exited with code 0)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ERROR: language "plpython3u" already exists

! gpconfig -c runaway_detector_activation_percent -v 100;

! gpstop -rai;
! gpstop -raf;
-- end_ignore

-- after the restart we need a new connection to run the queries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ERROR: language "plpython3u" already exists

! gpconfig -c runaway_detector_activation_percent -v 100;

! gpstop -rai;
! gpstop -raf;
-- end_ignore

-- after the restart we need a new connection to run the queries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ALTER RESOURCE GROUP


-- start_ignore
! gpstop -rai;
! gpstop -raf;
-- end_ignore

-- Cleanup in a new connection as the default one is disconnected by gpstop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- start_ignore
! gpconfig -r gp_resource_manager;

! gpstop -rai;
! gpstop -ra;

SHOW gp_resource_manager;
gp_resource_manager
Expand Down
4 changes: 2 additions & 2 deletions src/test/isolation2/expected/resgroup/resgroup_syntax.out
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ DROP
-- start_ignore
-- end_ignore
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- start_ignore
-- end_ignore
(exited with code 0)
Expand All @@ -579,7 +579,7 @@ DROP
-- start_ignore
-- end_ignore
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- start_ignore
-- end_ignore
(exited with code 0)
Expand Down
4 changes: 2 additions & 2 deletions src/test/isolation2/init_file_isolation2
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ m/.*Process \d+ waits for ExclusiveLock on resource queue \d+; blocked by proces
s/.*Process \d+ waits for ExclusiveLock on resource queue \d+; blocked by process \d+./Process PID waits for ExclusiveLock on resource queue OID; blocked by process PID./

# For resource queue self-deadlock detail
m/resource queue id: \d+, portal id: \d+/
s/resource queue id: \d+, portal id: \d+/resource queue id: OID, portal id: NUM/
m/resource queue id: (\d+|XXXX), portal id: \d+/
s/resource queue id: (\d+|XXXX), portal id: \d+/resource queue id: OID, portal id: NUM/

m/^Process \d+ waits for ShareLock on transaction \d+; blocked by process \d+./
s/^Process \d+ waits for ShareLock on transaction \d+; blocked by process \d+./Process PID waits for ShareLock on transaction XID; blocked by process PID./
Expand Down
17 changes: 17 additions & 0 deletions src/test/isolation2/input/uao/ao_unique_index_vacuum.source
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,22 @@ CREATE TABLE unique_index_vacuum_@amname@(i int UNIQUE) USING @amname@
INSERT INTO unique_index_vacuum_@amname@ SELECT generate_series(1, 5);
DELETE FROM unique_index_vacuum_@amname@ WHERE i = 5;

-- Enable debug logging to diagnose flaky compaction behavior.
SET debug_appendonly_print_compaction = on;
SET debug_appendonly_print_segfile_choice = on;
SET debug_appendonly_print_visimap = on;

select gp_inject_fault_infinite('vacuum_ao_after_index_delete', 'skip', dbid)
from gp_segment_configuration where role = 'p' AND content <> -1;

-- The first VACUUM performs COMPACT (marks old segfile AWAITING_DROP) and
-- POST_CLEANUP. Due to a race condition, POST_CLEANUP's cutoff XID check in
-- AppendOptimizedCollectDeadSegments() may find the AWAITING_DROP segment's
-- xmin too new, resulting in an empty dead_segs bitmap and scan_index() being
-- called instead of vacuum_appendonly_index() (which has the fault injector).
-- The second VACUUM guarantees the xid is old enough for the dead segment to
-- be collected, ensuring the fault is triggered.
VACUUM unique_index_vacuum_@amname@;
VACUUM unique_index_vacuum_@amname@;

-- Wait until all old index entries have been deleted by the VACUUM.
Expand All @@ -64,4 +77,8 @@ SELECT gp_wait_until_triggered_fault('vacuum_ao_after_index_delete', 1, dbid)
SELECT gp_inject_fault_infinite('vacuum_ao_after_index_delete', 'reset', dbid)
FROM gp_segment_configuration WHERE role = 'p' AND content <> -1;

RESET debug_appendonly_print_compaction;
RESET debug_appendonly_print_segfile_choice;
RESET debug_appendonly_print_visimap;

DROP TABLE unique_index_vacuum_@amname@;
4 changes: 2 additions & 2 deletions src/test/isolation2/input/workfile_mgr_test.source
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ language plpgsql volatile execute on all segments;

-- start_ignore
!\retcode gpconfig -c gp_workfile_max_entries -v 32 --skipvalidation;
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- end_ignore

-- setup for workfile made in temp tablespace test
Expand All @@ -80,7 +80,7 @@ language plpgsql volatile execute on all segments;

-- start_ignore
!\retcode gpconfig -r gp_workfile_max_entries --skipvalidation;
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- end_ignore

-- test workset cleanup
Expand Down
24 changes: 24 additions & 0 deletions src/test/isolation2/output/uao/ao_unique_index_vacuum.source
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ INSERT 5
DELETE FROM unique_index_vacuum_@amname@ WHERE i = 5;
DELETE 1

-- Enable debug logging to diagnose flaky compaction behavior.
SET debug_appendonly_print_compaction = on;
SET
SET debug_appendonly_print_segfile_choice = on;
SET
SET debug_appendonly_print_visimap = on;
SET

select gp_inject_fault_infinite('vacuum_ao_after_index_delete', 'skip', dbid) from gp_segment_configuration where role = 'p' AND content <> -1;
gp_inject_fault_infinite
--------------------------
Expand All @@ -91,6 +99,15 @@ select gp_inject_fault_infinite('vacuum_ao_after_index_delete', 'skip', dbid) fr
Success:
(3 rows)

-- The first VACUUM performs COMPACT (marks old segfile AWAITING_DROP) and
-- POST_CLEANUP. Due to a race condition, POST_CLEANUP's cutoff XID check in
-- AppendOptimizedCollectDeadSegments() may find the AWAITING_DROP segment's
-- xmin too new, resulting in an empty dead_segs bitmap and scan_index() being
-- called instead of vacuum_appendonly_index() (which has the fault injector).
-- The second VACUUM guarantees the xid is old enough for the dead segment to
-- be collected, ensuring the fault is triggered.
VACUUM unique_index_vacuum_@amname@;
VACUUM
VACUUM unique_index_vacuum_@amname@;
VACUUM

Expand All @@ -112,5 +129,12 @@ SELECT gp_inject_fault_infinite('vacuum_ao_after_index_delete', 'reset', dbid) F
Success:
(3 rows)

RESET debug_appendonly_print_compaction;
RESET
RESET debug_appendonly_print_segfile_choice;
RESET
RESET debug_appendonly_print_visimap;
RESET

DROP TABLE unique_index_vacuum_@amname@;
DROP
4 changes: 2 additions & 2 deletions src/test/isolation2/output/workfile_mgr_test.source
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CREATE

-- end_ignore
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- start_ignore
20200923:12:05:57:014232 gpstop:mdw:gpadmin-[INFO]:-Starting gpstop with args: -ari
20200923:12:05:57:014232 gpstop:mdw:gpadmin-[INFO]:-Gathering information and validating the environment...
Expand Down Expand Up @@ -132,7 +132,7 @@ DROP

-- end_ignore
(exited with code 0)
!\retcode gpstop -ari;
!\retcode gpstop -arf;
-- start_ignore
20200923:12:08:05:016154 gpstop:mdw:gpadmin-[INFO]:-Starting gpstop with args: -ari
20200923:12:08:05:016154 gpstop:mdw:gpadmin-[INFO]:-Gathering information and validating the environment...
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/sql/bitmap_index_crash.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ create index on test_bitmap using bitmap(type);
select count(*) from test_bitmap where type = 520;

-- start_ignore
! gpstop -rai;
! gpstop -raf;
-- end_ignore

0: select count(*) from test_bitmap where type = 520;
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/sql/gdd/end.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ALTER SYSTEM RESET gp_global_deadlock_detector_period;
-- Use utility session on seg 0 to restart master. This way avoids the
-- situation where session issuing the restart doesn't disappear
-- itself.
1U:SELECT pg_ctl(dir, 'restart') from datadir;
1U:SELECT pg_ctl(dir, 'restart', 'fast') from datadir;
-- Start new session on master to make sure it has fully completed
-- recovery and up and running again.
1: SHOW gp_enable_global_deadlock_detector;
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/sql/gdd/prepare.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ALTER SYSTEM SET gp_global_deadlock_detector_period TO 5;
-- Use utility session on seg 0 to restart master. This way avoids the
-- situation where session issuing the restart doesn't disappear
-- itself.
1U:SELECT pg_ctl(dir, 'restart') from datadir;
1U:SELECT pg_ctl(dir, 'restart', 'fast') from datadir;
-- Start new session on master to make sure it has fully completed
-- recovery and up and running again.
1: SHOW gp_enable_global_deadlock_detector;
Expand Down
2 changes: 1 addition & 1 deletion src/test/isolation2/sql/instr_in_shmem_setup.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- start_ignore
! gpconfig -c gp_enable_query_metrics -v on;
! gpstop -rai;
! gpstop -raf;
-- end_ignore
Loading
Loading