Quelle 010_keep_recycled_wals.pl
Sprache: unbekannt
# Copyright (c) 2021-2025, PostgreSQL Global Development Group # # Test situation where a target data directory contains # WAL files that were already recycled by the new primary. #
use strict;
use warnings FATAL => 'all';
use PostgreSQL::Test::Utils;
use Test::More;
use FindBin;
use lib $FindBin::RealBin;
use RewindTest;
RewindTest::primary_psql("CHECKPOINT"); # last common checkpoint
# We use `perl -e "exit(1)"` as an alternative to "false", because the latter # might not be available on Windows.
my $false = "$^X -e \"exit(1)\"";
$node_primary->append_conf( 'postgresql.conf', qq(
archive_command = '$false'
));
$node_primary->reload();
# advance WAL on primary; this WAL segment will never make it to the archive
RewindTest::primary_psql("CREATE TABLE t(a int)");
RewindTest::primary_psql("INSERT INTO t VALUES(0)");
RewindTest::primary_psql("SELECT pg_switch_wal()");
RewindTest::promote_standby;
# new primary loses diverging WAL segment
RewindTest::standby_psql("INSERT INTO t values(0)");
RewindTest::standby_psql("SELECT pg_switch_wal()");