Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fcd77d5

Browse files
committed
TAP test for logical decoding on standby
Author: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com> Author: Amit Khandekar <amitdkhan.pg@gmail.com> Author: Craig Ringer <craig@2ndquadrant.com> (in an older version) Author: Andres Freund <andres@anarazel.de> Reviewed-by: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
1 parent 0fdab27 commit fcd77d5

File tree

3 files changed

+772
-0
lines changed

3 files changed

+772
-0
lines changed

src/test/perl/PostgreSQL/Test/Cluster.pm

+37
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,43 @@ $SIG{TERM} = $SIG{INT} = sub {
30293029

30303030
=pod
30313031
3032+
=item $node->create_logical_slot_on_standby(self, primary, slot_name, dbname)
3033+
3034+
Create logical replication slot on given standby
3035+
3036+
=cut
3037+
3038+
sub create_logical_slot_on_standby
3039+
{
3040+
my ($self, $primary, $slot_name, $dbname) = @_;
3041+
my ($stdout, $stderr);
3042+
3043+
my $handle;
3044+
3045+
$handle = IPC::Run::start(['pg_recvlogical', '-d', $self->connstr($dbname), '-P', 'test_decoding', '-S', $slot_name, '--create-slot'], '>', \$stdout, '2>', \$stderr);
3046+
3047+
# Once the slot's restart_lsn is determined, the standby looks for
3048+
# xl_running_xacts WAL record from the restart_lsn onwards. First wait
3049+
# until the slot restart_lsn is determined.
3050+
3051+
$self->poll_query_until(
3052+
'postgres', qq[
3053+
SELECT restart_lsn IS NOT NULL
3054+
FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name'
3055+
]) or die "timed out waiting for logical slot to calculate its restart_lsn";
3056+
3057+
# Then arrange for the xl_running_xacts record for which pg_recvlogical is
3058+
# waiting.
3059+
$primary->safe_psql('postgres', 'SELECT pg_log_standby_snapshot()');
3060+
3061+
$handle->finish();
3062+
3063+
is($self->slot($slot_name)->{'slot_type'}, 'logical', $slot_name . ' on standby created')
3064+
or die "could not create slot" . $slot_name;
3065+
}
3066+
3067+
=pod
3068+
30323069
=back
30333070
30343071
=cut

src/test/recovery/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ tests += {
4040
't/032_relfilenode_reuse.pl',
4141
't/033_replay_tsp_drops.pl',
4242
't/034_create_database.pl',
43+
't/035_standby_logical_decoding.pl',
4344
],
4445
},
4546
}

0 commit comments

Comments
 (0)