Commit 6078770c authored by Noah Misch's avatar Noah Misch

In tests, await an LSN no later than the recovery target.

Otherwise, the test fails with "Timed out while waiting for standby to
catch up".  This happened rarely, perhaps only when autovacuum wrote WAL
between our choosing the recovery target and choosing the LSN to await.
Commit b26f7fa6 fixed one case of this.
Fix two more.  Back-patch to 9.6, which introduced the affected test.

Discussion: https://postgr.es/m/20180101055227.GA2952815@rfd.leadboat.com
parent 3e724aac
...@@ -5,8 +5,9 @@ use PostgresNode; ...@@ -5,8 +5,9 @@ use PostgresNode;
use TestLib; use TestLib;
use Test::More tests => 9; use Test::More tests => 9;
# Create and test a standby from given backup, with a certain # Create and test a standby from given backup, with a certain recovery target.
# recovery target. # Choose $until_lsn later than the transaction commit that causes the row
# count to reach $num_rows, yet not later than the recovery target.
sub test_recovery_standby sub test_recovery_standby
{ {
my $test_name = shift; my $test_name = shift;
...@@ -70,9 +71,9 @@ my ($lsn2, $recovery_txid) = split /\|/, $ret; ...@@ -70,9 +71,9 @@ my ($lsn2, $recovery_txid) = split /\|/, $ret;
# More data, with recovery target timestamp # More data, with recovery target timestamp
$node_master->safe_psql('postgres', $node_master->safe_psql('postgres',
"INSERT INTO tab_int VALUES (generate_series(2001,3000))"); "INSERT INTO tab_int VALUES (generate_series(2001,3000))");
$ret = my $lsn3 =
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn(), now();"); $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
my ($lsn3, $recovery_time) = split /\|/, $ret; my $recovery_time = $node_master->safe_psql('postgres', "SELECT now()");
# Even more data, this time with a recovery target name # Even more data, this time with a recovery target name
$node_master->safe_psql('postgres', $node_master->safe_psql('postgres',
...@@ -86,10 +87,8 @@ $node_master->safe_psql('postgres', ...@@ -86,10 +87,8 @@ $node_master->safe_psql('postgres',
# And now for a recovery target LSN # And now for a recovery target LSN
$node_master->safe_psql('postgres', $node_master->safe_psql('postgres',
"INSERT INTO tab_int VALUES (generate_series(4001,5000))"); "INSERT INTO tab_int VALUES (generate_series(4001,5000))");
my $recovery_lsn = my $lsn5 = my $recovery_lsn =
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()"); $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()");
my $lsn5 =
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
$node_master->safe_psql('postgres', $node_master->safe_psql('postgres',
"INSERT INTO tab_int VALUES (generate_series(5001,6000))"); "INSERT INTO tab_int VALUES (generate_series(5001,6000))");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment