diff options
author | Amit Kapila <akapila@postgresql.org> | 2023-04-27 14:22:53 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2023-04-27 14:22:53 +0530 |
commit | 376dc820531bafcbf105fff74c5b14c23d9950af (patch) | |
tree | 750de45f7e6c3a8ef62ee13044228d087ede2911 /src/test/perl/PostgreSQL/Test | |
parent | bedc1f0564d12c4a89fc9de3044201166542dc3d (diff) | |
download | postgresql-376dc820531bafcbf105fff74c5b14c23d9950af.tar.gz postgresql-376dc820531bafcbf105fff74c5b14c23d9950af.zip |
Add a test to verify that subscription to the standby works.
Author: Bertrand Drouvot
Reviewed-by: Vignesh C, Alvaro Herrera, Amit Kapila
Discussion: https://postgr.es/m/2fefa454-5a70-2174-ddbf-4a0e41537139@gmail.com
Diffstat (limited to 'src/test/perl/PostgreSQL/Test')
-rw-r--r-- | src/test/perl/PostgreSQL/Test/Cluster.pm | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm index 6f7f4e5de4c..bc9b5dc6444 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -2611,8 +2611,14 @@ When doing physical replication, the standby is usually identified by passing its PostgreSQL::Test::Cluster instance. When doing logical replication, standby_name identifies a subscription. -The default value of target_lsn is $node->lsn('write'), which ensures -that the standby has caught up to what has been committed on the primary. +When not in recovery, the default value of target_lsn is $node->lsn('write'), +which ensures that the standby has caught up to what has been committed on +the primary. + +When in recovery, the default value of target_lsn is $node->lsn('replay') +instead which ensures that the cascaded standby has caught up to what has been +replayed on the standby. + If you pass an explicit value of target_lsn, it should almost always be the primary's write LSN; so this parameter is seldom needed except when querying some intermediate replication node rather than the primary. @@ -2644,7 +2650,16 @@ sub wait_for_catchup } if (!defined($target_lsn)) { - $target_lsn = $self->lsn('write'); + my $isrecovery = $self->safe_psql('postgres', "SELECT pg_is_in_recovery()"); + chomp($isrecovery); + if ($isrecovery eq 't') + { + $target_lsn = $self->lsn('replay'); + } + else + { + $target_lsn = $self->lsn('write'); + } } print "Waiting for replication conn " . $standby_name . "'s " |