Skip to content

Commit 9052b7a

Browse files
committed
PAX stats test: wait for seq_tup_read before exiting wait_for_stats()
In Cloudberry's MPP architecture, segment stats are delivered asynchronously to the coordinator. The seq_scan counter can be registered before seq_tup_read arrives from segments, causing wait_for_stats() to exit prematurely and the subsequent assertion to fail intermittently in the pax-ic-good-opt-off CI job. Add an explicit wait condition (updated6) for seq_tup_read reaching the expected value, and update the comment to reflect Cloudberry's segment-level async stats delivery rather than parallel workers.
1 parent 81a5f31 commit 9052b7a

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

contrib/pax_storage/src/test/regress/expected/stats.out

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ declare
3434
updated3 bool;
3535
updated4 bool;
3636
updated5 bool;
37+
updated6 bool;
3738
begin
3839
-- we don't want to wait forever; loop will exit after 30 seconds
3940
for i in 1 .. 300 loop
4041

41-
-- With parallel query, the seqscan and indexscan on tenk2 might be done
42-
-- in parallel worker processes, which will send their stats counters
43-
-- asynchronously to what our own session does. So we must check for
44-
-- those counts to be registered separately from the update counts.
42+
-- Segment stats are sent asynchronously to the coordinator, so we must
43+
-- check for each counter independently to avoid false exits.
4544

4645
-- check to see if seqscan has been sensed
4746
SELECT (st.seq_scan >= pr.seq_scan + 1) INTO updated1
@@ -68,7 +67,13 @@ begin
6867
FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
6968
WHERE st.relname='tenk2' AND cl.relname='tenk2';
7069

71-
exit when updated1 and updated2 and updated3 and updated4 and updated5;
70+
-- check to see if seq_tup_read has been sensed; segment stats may arrive
71+
-- after seq_scan count, so wait for this explicitly
72+
SELECT (st.seq_tup_read >= pr.seq_tup_read + cl.reltuples) INTO updated6
73+
FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
74+
WHERE st.relname='tenk2' AND cl.relname='tenk2';
75+
76+
exit when updated1 and updated2 and updated3 and updated4 and updated5 and updated6;
7277

7378
-- wait a little
7479
perform pg_sleep_for('100 milliseconds');

contrib/pax_storage/src/test/regress/sql/stats.sql

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ declare
3333
updated3 bool;
3434
updated4 bool;
3535
updated5 bool;
36+
updated6 bool;
3637
begin
3738
-- we don't want to wait forever; loop will exit after 30 seconds
3839
for i in 1 .. 300 loop
3940

40-
-- With parallel query, the seqscan and indexscan on tenk2 might be done
41-
-- in parallel worker processes, which will send their stats counters
42-
-- asynchronously to what our own session does. So we must check for
43-
-- those counts to be registered separately from the update counts.
41+
-- Segment stats are sent asynchronously to the coordinator, so we must
42+
-- check for each counter independently to avoid false exits.
4443

4544
-- check to see if seqscan has been sensed
4645
SELECT (st.seq_scan >= pr.seq_scan + 1) INTO updated1
@@ -67,7 +66,13 @@ begin
6766
FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
6867
WHERE st.relname='tenk2' AND cl.relname='tenk2';
6968

70-
exit when updated1 and updated2 and updated3 and updated4 and updated5;
69+
-- check to see if seq_tup_read has been sensed; segment stats may arrive
70+
-- after seq_scan count, so wait for this explicitly
71+
SELECT (st.seq_tup_read >= pr.seq_tup_read + cl.reltuples) INTO updated6
72+
FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
73+
WHERE st.relname='tenk2' AND cl.relname='tenk2';
74+
75+
exit when updated1 and updated2 and updated3 and updated4 and updated5 and updated6;
7176

7277
-- wait a little
7378
perform pg_sleep_for('100 milliseconds');

0 commit comments

Comments
 (0)