1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Add PostgreSQL::Test::Cluster::advance_wal

This is a function that makes a node jump by N WAL segments, which is
something a couple of tests have been relying on for some cases related
to streaming, replication slot limits and logical decoding on standbys.
Hence, this centralizes the logic, while making it cheaper by relying on
pg_logical_emit_message() to emit WAL records before switching to a new
segment.

Author: Bharath Rupireddy
Reviewed-by: Kyotaro Horiguchi, Euler Taveira
Discussion: https://postgr.es/m/CALj2ACU3R8QFCvDewHCMKjgb2w_-CMCyd6DAK=Jb-af14da5eg@mail.gmail.com
This commit is contained in:
Michael Paquier
2023-12-21 10:19:17 +09:00
parent bf6260b39d
commit c161ab74f7
4 changed files with 42 additions and 45 deletions

View File

@@ -3197,6 +3197,31 @@ sub create_logical_slot_on_standby
=pod
=item $node->advance_wal(num)
Advance WAL of node by given number of segments.
=cut
sub advance_wal
{
my ($self, $num) = @_;
# Advance by $n segments (= (wal_segment_size * $num) bytes).
# pg_switch_wal() forces a WAL flush, making pg_logical_emit_message()
# safe to use in non-transactional mode.
for (my $i = 0; $i < $num; $i++)
{
$self->safe_psql(
'postgres', qq{
SELECT pg_logical_emit_message(false, '', 'foo');
SELECT pg_switch_wal();
});
}
}
=pod
=back
=cut