v1-0001-Use-WAIT-FOR-LSN-in-PostgreSQL-Test-Cluster-wait_.patch
application/octet-stream
Filename: v1-0001-Use-WAIT-FOR-LSN-in-PostgreSQL-Test-Cluster-wait_.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v1-0001
Subject: Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup()
| File | + | − |
|---|---|---|
| src/test/perl/PostgreSQL/Test/Cluster.pm | 25 | 2 |
From bb12721dc3efbd213416adb8c3563bb0c11c023b Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Wed, 5 Nov 2025 11:10:04 +0200
Subject: [PATCH v1] Use WAIT FOR LSN in
PostgreSQL::Test::Cluster::wait_for_catchup()
---
src/test/perl/PostgreSQL/Test/Cluster.pm | 27 ++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 35413f14019..85b5d9863cd 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -3328,6 +3328,8 @@ sub wait_for_catchup
$mode = defined($mode) ? $mode : 'replay';
my %valid_modes =
('sent' => 1, 'write' => 1, 'flush' => 1, 'replay' => 1);
+ my $isrecovery =
+ $self->safe_psql('postgres', "SELECT pg_is_in_recovery()");
croak "unknown mode $mode for 'wait_for_catchup', valid modes are "
. join(', ', keys(%valid_modes))
unless exists($valid_modes{$mode});
@@ -3340,8 +3342,6 @@ sub wait_for_catchup
}
if (!defined($target_lsn))
{
- my $isrecovery =
- $self->safe_psql('postgres', "SELECT pg_is_in_recovery()");
chomp($isrecovery);
if ($isrecovery eq 't')
{
@@ -3360,6 +3360,29 @@ sub wait_for_catchup
. $self->name . "\n";
# Before release 12 walreceiver just set the application name to
# "walreceiver"
+
+ # Use WAIT FOR LSN when appropriate
+ if (($mode eq 'replay') && ($isrecovery eq 't'))
+ {
+ my $query =
+ qq[WAIT FOR LSN '${target_lsn}' WITH (timeout '${PostgreSQL::Test::Utils::timeout_default}s', no_throw);];
+ my $output = $self->safe_psql('postgres', $query);
+
+ if ($output ne 'success')
+ {
+ # Fetch additional detail for debugging purposes
+ $query = qq[SELECT * FROM pg_catalog.pg_stat_replication];
+ my $details = $self->safe_psql('postgres', $query);
+ diag qq(WAIT FOR LSN failed with status:
+ ${output});
+ diag qq(Last pg_stat_replication contents:
+ ${details});
+ croak "failed waiting for catchup";
+ }
+ print "done\n";
+ return;
+ }
+
my $query = qq[SELECT '$target_lsn' <= ${mode}_lsn AND state = 'streaming'
FROM pg_catalog.pg_stat_replication
WHERE application_name IN ('$standby_name', 'walreceiver')];
--
2.39.5 (Apple Git-154)