mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Commit f82ec32ac30ae7e3ec7c84067192535b2ff8ec0e renamed the pg_xlog directory to pg_wal. To make things consistent, and because "xlog" is terrible terminology for either "transaction log" or "write-ahead log" rename all SQL-callable functions that contain "xlog" in the name to instead contain "wal". (Note that this may pose an upgrade hazard for some users.) Similarly, rename the xlog_position argument of the functions that create slots to be called wal_position. Discussion: https://www.postgresql.org/message-id/CA+Tgmob=YmA=H3DbW1YuOXnFVgBheRmyDkWcD9M8f=5bGWYEoQ@mail.gmail.com
66 lines
2.1 KiB
Perl
66 lines
2.1 KiB
Perl
# Test master/standby scenario where the track_commit_timestamp GUC is
|
|
# repeatedly toggled on and off.
|
|
use strict;
|
|
use warnings;
|
|
|
|
use TestLib;
|
|
use Test::More tests => 4;
|
|
use PostgresNode;
|
|
|
|
my $bkplabel = 'backup';
|
|
my $master = get_new_node('master');
|
|
$master->init(allows_streaming => 1);
|
|
$master->append_conf(
|
|
'postgresql.conf', qq{
|
|
track_commit_timestamp = on
|
|
max_wal_senders = 5
|
|
});
|
|
$master->start;
|
|
$master->backup($bkplabel);
|
|
|
|
my $standby = get_new_node('standby');
|
|
$standby->init_from_backup($master, $bkplabel, has_streaming => 1);
|
|
$standby->start;
|
|
|
|
for my $i (1 .. 10)
|
|
{
|
|
$master->safe_psql('postgres', "create table t$i()");
|
|
}
|
|
$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
|
|
$master->restart;
|
|
$master->safe_psql('postgres', 'checkpoint');
|
|
my $master_lsn =
|
|
$master->safe_psql('postgres', 'select pg_current_wal_location()');
|
|
$standby->poll_query_until('postgres',
|
|
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_location()})
|
|
or die "slave never caught up";
|
|
|
|
$standby->safe_psql('postgres', 'checkpoint');
|
|
$standby->restart;
|
|
|
|
my ($psql_ret, $standby_ts_stdout, $standby_ts_stderr) = $standby->psql(
|
|
'postgres',
|
|
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
|
|
);
|
|
is($psql_ret, 3, 'expect error when getting commit timestamp after restart');
|
|
is($standby_ts_stdout, '', "standby does not return a value after restart");
|
|
like(
|
|
$standby_ts_stderr,
|
|
qr/could not get commit timestamp data/,
|
|
'expected err msg after restart');
|
|
|
|
$master->append_conf('postgresql.conf', 'track_commit_timestamp = on');
|
|
$master->restart;
|
|
$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
|
|
$master->restart;
|
|
|
|
system_or_bail('pg_ctl', '-D', $standby->data_dir, 'promote');
|
|
$standby->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true");
|
|
|
|
$standby->safe_psql('postgres', "create table t11()");
|
|
my $standby_ts = $standby->safe_psql('postgres',
|
|
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't11'}
|
|
);
|
|
isnt($standby_ts, '',
|
|
"standby gives valid value ($standby_ts) after promotion");
|