From 5bcb76299860631cb4c319b9e02679fa057d0387 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Wed, 2 Sep 2026 11:37:41 +0300
Subject: [PATCH v1] Stabilize test_custom_stats/001_custom_stats test

---
 .../test_custom_stats/t/001_custom_stats.pl   | 35 ++++++++++---------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/test/modules/test_custom_stats/t/001_custom_stats.pl b/src/test/modules/test_custom_stats/t/001_custom_stats.pl
index 69f2284229e..b2b895c008e 100644
--- a/src/test/modules/test_custom_stats/t/001_custom_stats.pl
+++ b/src/test/modules/test_custom_stats/t/001_custom_stats.pl
@@ -74,29 +74,30 @@ $node->safe_psql('postgres', q(select test_custom_stats_fixed_update()));
 $node->safe_psql('postgres', q(select test_custom_stats_fixed_update()));
 $node->safe_psql('postgres', q(select test_custom_stats_fixed_update()));
 
-# Test data reports.
-$result = $node->safe_psql('postgres',
-	q(select * from test_custom_stats_var_report('entry1')));
-is( $result,
-	"entry1|2|Test entry 1",
+# Test data reports.  The variable-sized updates are flushed by their backends
+# during process exit, so wait until they are visible.
+ok( $node->poll_query_until(
+		'postgres',
+		q(select * from test_custom_stats_var_report('entry1')),
+		"entry1|2|Test entry 1"),
 	"report for variable-sized data of entry1");
 
-$result = $node->safe_psql('postgres',
-	q(select * from test_custom_stats_var_report('entry2')));
-is( $result,
-	"entry2|3|Test entry 2",
+ok( $node->poll_query_until(
+		'postgres',
+		q(select * from test_custom_stats_var_report('entry2')),
+		"entry2|3|Test entry 2"),
 	"report for variable-sized data of entry2");
 
-$result = $node->safe_psql('postgres',
-	q(select * from test_custom_stats_var_report('entry3')));
-is( $result,
-	"entry3|2|Test entry 3",
+ok( $node->poll_query_until(
+		'postgres',
+		q(select * from test_custom_stats_var_report('entry3')),
+		"entry3|2|Test entry 3"),
 	"report for variable-sized data of entry3");
 
-$result = $node->safe_psql('postgres',
-	q(select * from test_custom_stats_var_report('entry4')));
-is( $result,
-	"entry4|3|Test entry 4",
+ok( $node->poll_query_until(
+		'postgres',
+		q(select * from test_custom_stats_var_report('entry4')),
+		"entry4|3|Test entry 4"),
 	"report for variable-sized data of entry4");
 
 $result = $node->safe_psql('postgres',
-- 
2.47.3

