Commit b26f7fa6 authored by Alvaro Herrera's avatar Alvaro Herrera

Fix assorted problems in recovery tests

In test 001_stream_rep we're using pg_stat_replication.write_location to
determine catch-up status, but we care about xlog having been applied
not just received, so change that to apply_location.

In test 003_recovery_targets, we query the database for a recovery
target specification and later for the xlog position supposedly
corresponding to that recovery specification.  If for whatever reason
more WAL is written between the two queries, the recovery specification
is earlier than the xlog position used by the query in the test harness,
so we wait forever, leading to test failures.  Deal with this by using a
single query to extract both items.  In 2a0f89cd we tried to deal
with it by giving them more tests to run, but in hindsight that was
obviously doomed to failure (no revert of that, though).

Per hamster buildfarm failures.

Author: Michaël Paquier
parent 69bdfc40
...@@ -38,11 +38,11 @@ $node_master->safe_psql('postgres', ...@@ -38,11 +38,11 @@ $node_master->safe_psql('postgres',
my $applname_1 = $node_standby_1->name; my $applname_1 = $node_standby_1->name;
my $applname_2 = $node_standby_2->name; my $applname_2 = $node_standby_2->name;
my $caughtup_query = my $caughtup_query =
"SELECT pg_current_xlog_location() <= write_location FROM pg_stat_replication WHERE application_name = '$applname_1';"; "SELECT pg_current_xlog_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$applname_1';";
$node_master->poll_query_until('postgres', $caughtup_query) $node_master->poll_query_until('postgres', $caughtup_query)
or die "Timed out while waiting for standby 1 to catch up"; or die "Timed out while waiting for standby 1 to catch up";
$caughtup_query = $caughtup_query =
"SELECT pg_last_xlog_replay_location() <= write_location FROM pg_stat_replication WHERE application_name = '$applname_2';"; "SELECT pg_last_xlog_replay_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$applname_2';";
$node_standby_1->poll_query_until('postgres', $caughtup_query) $node_standby_1->poll_query_until('postgres', $caughtup_query)
or die "Timed out while waiting for standby 2 to catch up"; or die "Timed out while waiting for standby 2 to catch up";
......
...@@ -66,17 +66,16 @@ $node_master->backup('my_backup'); ...@@ -66,17 +66,16 @@ $node_master->backup('my_backup');
# target TXID. # target TXID.
$node_master->safe_psql('postgres', $node_master->safe_psql('postgres',
"INSERT INTO tab_int VALUES (generate_series(1001,2000))"); "INSERT INTO tab_int VALUES (generate_series(1001,2000))");
my $recovery_txid = my $ret =
$node_master->safe_psql('postgres', "SELECT txid_current()"); $node_master->safe_psql('postgres', "SELECT pg_current_xlog_location(), txid_current();");
my $lsn2 = my ($lsn2, $recovery_txid) = split /\|/, $ret;
$node_master->safe_psql('postgres', "SELECT pg_current_xlog_location();");
# 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))");
my $recovery_time = $node_master->safe_psql('postgres', "SELECT now()"); $ret =
my $lsn3 = $node_master->safe_psql('postgres', "SELECT pg_current_xlog_location(), now();");
$node_master->safe_psql('postgres', "SELECT pg_current_xlog_location();"); my ($lsn3, $recovery_time) = split /\|/, $ret;
# 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',
......
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