pgsql: Stabilize recovery conflict stats checks in 031_recovery_conflic

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Stabilize recovery conflict stats checks in 031_recovery_conflic
Date: 2026-09-03 03:18:23
Message-ID: E1x1xy2-00000003GD8-17zG@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

The buildfarm member akepa reported a failure in the
031_recovery_conflict.pl test.

The test checked pg_stat_database_conflicts immediately after detecting
a recovery conflict in the standby log. However, the conflict counter is
flushed by the canceled backend during backend exit, so WAL replay
completion and the log message did not guarantee that the updated
statistics are visible yet. So, previously, the test could see a conflict
counter of 0 even though the conflict had already occurred, triggering
the test failure.

Fix this by polling for the expected conflict counter instead of reading
it only once, handling the asynchronous pgstats update.

Per buildfarm member akepa.

Backpatch to v17, where this test is enabled and has the same race.

Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHGQGwHmiLNRfvJDAR=PmxQgf7DbzPSO1M-1RoqO8oy=t2G5KA@mail.gmail.com
Backpatch-through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8254de34bc4226756755ee585c0e24dd995e12a2

Modified Files
--------------
src/test/recovery/t/031_recovery_conflict.pl | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-09-03 03:18:34 pgsql: Avoid backend hang during temp table cleanup in deferrable trans
Previous Message Fujii Masao 2026-09-03 03:17:58 pgsql: Avoid backend hang during temp table cleanup in deferrable trans