mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Stabilize recovery conflict count checks in 031_recovery_conflict.pl
Buildfarm members olingo and adder reported failures in 031_recovery_conflict.pl where a recovery conflict was counted twice. olingo saw the snapshot conflict count reach 2 instead of 1, while adder saw the same for the buffer pin conflict count. The startup process can signal a standby backend again while it is reporting a recovery-conflict FATAL error. Each processed conflict can increment the corresponding statistic. Thus, even when the expected conflict occurs, its counter can exceed 1. The existing poll for exactly 1 can then time out, and the exact check of the aggregate count can fail as well. Fix this by polling for a positive count for each conflict type and accepting an aggregate count of at least the expected number. Backpatch to v17, where this test was enabled. Reported-by: Alexander Lakhin <exclusion@gmail.com> Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com> Reviewed-by: Alexander Lakhin <exclusion@gmail.com> Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/421c0aee-84c8-4c07-b4b9-263095479755%40gmail.com Backpatch-through: 17
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user