(unnamed)
text/plain
# Copyright (c) 2021, PostgreSQL Global Development Group
#
# Tests related to WAL archiving and recovery.
#
use strict;
use warnings;
use PostgresNode;
use TestLib;
use Test::More tests => 1;
use Config;
my $backup_name='mybackup';
my $primary = get_new_node('primary');
$primary->init(
has_archiving => 1,
allows_streaming => 1);
$primary->append_conf('postgresql.conf', qq[
wal_keep_size=128MB
archive_mode=always
log_checkpoints=yes
]);
my $primary_archive = $primary->archive_dir;
$primary->start;
$primary->backup($backup_name);
my $standby = get_new_node('standby');
my $standby_archive = $standby->archive_dir;
$standby->init_from_backup($primary, $backup_name, has_streaming=>1);
$standby->append_conf('postgresql.conf', qq[
restore_command='cp $primary_archive/%f %p'
archive_command='test ! -f $standby_archive/%f && cp %p $standby_archive/%f'
]);
$standby->start;
$primary->psql('postgres', 'CHECKPOINT;SELECT pg_switch_wal();CREATE TABLE t(); pg_switch_wal();');
$standby->psql('postgres', 'CHECKPOINT');
$standby->stop('immediate');
$standby->start;
$primary->psql('postgres', 'CHECKPOINT;SELECT pg_switch_wal();CHECKPOINT');
$standby->psql('postgres', 'CHECKPOINT');
my $result;
while (1) {
$result =
$standby->safe_psql('postgres',
"SELECT last_archived_wal, last_failed_wal FROM pg_stat_archiver");
sleep(0.1);
last if ($result ne "|");
}
ok($result =~ /^[^|]+\|$/, 'archive check 1');