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"); }