From 2a5b01a1f55235ff27c907622e29a9249c891911 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Fri, 4 Sep 2026 02:50:30 +0530 Subject: [PATCH v1 1/2] Stabilize recovery conflict count checks The startup process can send a backend more than one recovery conflict signal while the backend is reporting a FATAL error. Each processed signal can increment the statistics, so a per-type counter may advance past one and the aggregate counter may exceed the number of scenarios exercised by the test. The test only needs to verify that each requested conflict type was recorded. Poll for a positive per-type counter, and require the aggregate counter to be at least the number of conflicts induced by the test. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/421c0aee-84c8-4c07-b4b9-263095479755%40gmail.com Backpatch-through: 17 --- src/test/recovery/t/031_recovery_conflict.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/test/recovery/t/031_recovery_conflict.pl b/src/test/recovery/t/031_recovery_conflict.pl index c87acd20e0a..ae9434f12a5 100644 --- a/src/test/recovery/t/031_recovery_conflict.pl +++ b/src/test/recovery/t/031_recovery_conflict.pl @@ -281,13 +281,17 @@ $node_standby->restart(); $psql_standby->reconnect_and_clear(); -# Check that expected number of conflicts show in pg_stat_database. Needs to -# be tested before database is dropped, for obvious reasons. -is( $node_standby->safe_psql( +# Check that at least the expected number of conflicts show in +# pg_stat_database. Needs to be tested before database is dropped, for obvious +# reasons. A backend can process the same recovery conflict more than once +# before it exits. +cmp_ok( $node_standby->safe_psql( $test_db, qq[SELECT conflicts FROM pg_stat_database WHERE datname='$test_db';]), + '>=', $expected_conflicts, - qq[$expected_conflicts recovery conflicts shown in pg_stat_database]); + qq[at least $expected_conflicts recovery conflicts shown in pg_stat_database] +); ## RECOVERY CONFLICT 6: Database conflict @@ -328,7 +332,7 @@ sub check_conflict_stat ok( $node_standby->poll_query_until( $test_db, - qq[SELECT confl_$conflict_type FROM pg_stat_database_conflicts WHERE datname='$test_db';], - '1'), + qq[SELECT confl_$conflict_type > 0 FROM pg_stat_database_conflicts WHERE datname='$test_db';], + 't'), "$sect: stats show conflict on standby"); } base-commit: 534db08f972852b77ea5e96e77d5fe45f3d8df93 -- 2.34.1