You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by le...@apache.org on 2026/10/08 10:22:10 UTC
(cloudberry) 07/08: Fix synchronization in vacuum progress isolation tests
This is an automated email from the ASF dual-hosted git repository.
leborchuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 126cfedb0c70314ca2fd77ae7a3c45e3785ec51a
Author: Alena Rybakina <al...@gmail.com>
AuthorDate: Wed Sep 30 18:21:00 2026 +0300
Fix synchronization in vacuum progress isolation tests
---
.../isolation2/expected/vacuum_progress_column.out | 17 ++++++++--------
.../isolation2/expected/vacuum_progress_row.out | 23 +++++++++++++---------
src/test/isolation2/sql/vacuum_progress_column.sql | 11 +++++------
src/test/isolation2/sql/vacuum_progress_row.sql | 15 +++++++-------
4 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/src/test/isolation2/expected/vacuum_progress_column.out b/src/test/isolation2/expected/vacuum_progress_column.out
index 30055afcaaa..40bce79477a 100644
--- a/src/test/isolation2/expected/vacuum_progress_column.out
+++ b/src/test/isolation2/expected/vacuum_progress_column.out
@@ -41,11 +41,10 @@ ABORT
1: ABORT;
ABORT
--- Look up the collected stats before the DELETE below. The stats collector
--- is asynchronous: wait until it has received the dead tuples of both
--- aborted inserts, and read the view before the DELETE, whose own counts
--- may reach the collector at any moment after it.
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 200000);
+-- Wait on the coordinator for the statistics of both aborted inserts, since
+-- the following pg_stat_all_tables query also runs there. Read before DELETE
+-- so its statistics cannot race with this check.
+-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 200000);
wait_until_dead_tup_change_to
-------------------------------
OK
@@ -237,10 +236,10 @@ VACUUM
(0 rows)
-- pg_class and collected stats view should be updated after the 2nd VACUUM
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 0);
- wait_until_dead_tup_change_to
--------------------------------
- OK
+1U: SELECT wait_until_vacuum_count_change_to('vacuum_progress_ao_column'::regclass::oid, 2);
+ wait_until_vacuum_count_change_to
+-----------------------------------
+ OK
(1 row)
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_column';
relpages | reltuples | relallvisible
diff --git a/src/test/isolation2/expected/vacuum_progress_row.out b/src/test/isolation2/expected/vacuum_progress_row.out
index d700968c324..300f9ad8949 100644
--- a/src/test/isolation2/expected/vacuum_progress_row.out
+++ b/src/test/isolation2/expected/vacuum_progress_row.out
@@ -40,11 +40,10 @@ ABORT
1: ABORT;
ABORT
--- Look up the collected stats before the DELETE below. The stats collector
--- is asynchronous: wait until it has received the dead tuples of both
--- aborted inserts, and read the view before the DELETE, whose own counts
--- may reach the collector at any moment after it.
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_row'::regclass::oid, 200000);
+-- Wait on the coordinator for the statistics of both aborted inserts, since
+-- the following pg_stat_all_tables query also runs there. Read before DELETE
+-- so its statistics cannot race with this check.
+-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_row'::regclass::oid, 200000);
wait_until_dead_tup_change_to
-------------------------------
OK
@@ -73,11 +72,14 @@ SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', '',
1: set Debug_appendonly_print_compaction to on;
SET
1&: VACUUM vacuum_progress_ao_row; <waiting ...>
-SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 2, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+-- Wait for all primaries, since the summary below includes every segment.
+SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 2, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
-- We are in pre_cleanup phase and some blocks should've been vacuumed by now
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
@@ -105,11 +107,14 @@ SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid)
Success:
Success:
(3 rows)
-SELECT gp_wait_until_triggered_fault('appendonly_insert', 200, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+-- Wait for all primaries, since the summary below includes every segment.
+SELECT gp_wait_until_triggered_fault('appendonly_insert', 200, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
-- We are in compact phase. num_dead_tuples should increase as we move and count tuples, one by one.
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
diff --git a/src/test/isolation2/sql/vacuum_progress_column.sql b/src/test/isolation2/sql/vacuum_progress_column.sql
index 6ed4744a2b8..19bd474a0ae 100644
--- a/src/test/isolation2/sql/vacuum_progress_column.sql
+++ b/src/test/isolation2/sql/vacuum_progress_column.sql
@@ -27,11 +27,10 @@ CREATE INDEX on vacuum_progress_ao_column(j);
-- Abort so that segno 1 has logical EOF = 0.
1: ABORT;
--- Look up the collected stats before the DELETE below. The stats collector
--- is asynchronous: wait until it has received the dead tuples of both
--- aborted inserts, and read the view before the DELETE, whose own counts
--- may reach the collector at any moment after it.
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 200000);
+-- Wait on the coordinator for the statistics of both aborted inserts, since
+-- the following pg_stat_all_tables query also runs there. Read before DELETE
+-- so its statistics cannot race with this check.
+-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 200000);
SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_column';
-- Also delete half of the tuples evenly before the EOF of segno 2.
@@ -100,7 +99,7 @@ SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid)
1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
-- pg_class and collected stats view should be updated after the 2nd VACUUM
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 0);
+1U: SELECT wait_until_vacuum_count_change_to('vacuum_progress_ao_column'::regclass::oid, 2);
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_column';
-- SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_column' and gp_segment_id = 1;
diff --git a/src/test/isolation2/sql/vacuum_progress_row.sql b/src/test/isolation2/sql/vacuum_progress_row.sql
index 7b3749d7b70..8fde34ecddb 100644
--- a/src/test/isolation2/sql/vacuum_progress_row.sql
+++ b/src/test/isolation2/sql/vacuum_progress_row.sql
@@ -26,11 +26,10 @@ CREATE INDEX on vacuum_progress_ao_row(j);
-- Abort so that segno 1 has logical EOF = 0.
1: ABORT;
--- Look up the collected stats before the DELETE below. The stats collector
--- is asynchronous: wait until it has received the dead tuples of both
--- aborted inserts, and read the view before the DELETE, whose own counts
--- may reach the collector at any moment after it.
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_row'::regclass::oid, 200000);
+-- Wait on the coordinator for the statistics of both aborted inserts, since
+-- the following pg_stat_all_tables query also runs there. Read before DELETE
+-- so its statistics cannot race with this check.
+-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_row'::regclass::oid, 200000);
SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
-- Also delete half of the tuples evenly before the EOF of segno 2.
@@ -43,7 +42,8 @@ SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', '',
1: set Debug_appendonly_print_compaction to on;
1&: VACUUM vacuum_progress_ao_row;
-SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 2, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+-- Wait for all primaries, since the summary below includes every segment.
+SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 2, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- We are in pre_cleanup phase and some blocks should've been vacuumed by now
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
@@ -51,7 +51,8 @@ select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, he
-- Resume execution and suspend again in the middle of compact phase
SELECT gp_inject_fault('appendonly_insert', 'suspend', '', '', '', 200, 200, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-SELECT gp_wait_until_triggered_fault('appendonly_insert', 200, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+-- Wait for all primaries, since the summary below includes every segment.
+SELECT gp_wait_until_triggered_fault('appendonly_insert', 200, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- We are in compact phase. num_dead_tuples should increase as we move and count tuples, one by one.
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org