summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2017-07-01 18:25:09 +0000
committerTom Lane2017-07-01 18:25:09 +0000
commitb0f069d931f0a3d4a39aeeb230baf2f2b18cb3c3 (patch)
tree080a44f7a5fc251dfb2aded6361cc4d3a6ff20a1
parentf32678c0163d7d966560bdaf41bfbc2cf179a260 (diff)
Clean up misuse and nonuse of poll_query_until().
Several callers of PostgresNode::poll_query_until() neglected to check for failure; I do not think that's optional. Also, rewrite one place that had reinvented poll_query_until() for no very good reason.
-rw-r--r--src/test/modules/commit_ts/t/003_standby_2.pl3
-rw-r--r--src/test/perl/PostgresNode.pm2
-rw-r--r--src/test/recovery/t/001_stream_rep.pl3
-rw-r--r--src/test/recovery/t/005_replay_delay.pl20
-rw-r--r--src/test/recovery/t/006_logical_decoding.pl9
-rw-r--r--src/test/recovery/t/010_logical_decoding_timelines.pl7
6 files changed, 19 insertions, 25 deletions
diff --git a/src/test/modules/commit_ts/t/003_standby_2.pl b/src/test/modules/commit_ts/t/003_standby_2.pl
index 2fd561115c..eccaf07561 100644
--- a/src/test/modules/commit_ts/t/003_standby_2.pl
+++ b/src/test/modules/commit_ts/t/003_standby_2.pl
@@ -55,7 +55,8 @@ $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->poll_query_until('postgres', "SELECT NOT pg_is_in_recovery()")
+ or die "standby never exited recovery";
$standby->safe_psql('postgres', "create table t11()");
my $standby_ts = $standby->safe_psql('postgres',
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index e72c63580d..f4fa600951 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -43,7 +43,7 @@ PostgresNode - class representing PostgreSQL server instance
# run query every second until it returns 't'
# or times out
$node->poll_query_until('postgres', q|SELECT random() < 0.1;|')
- or print "timed out";
+ or die "timed out";
# Do an online pg_basebackup
my $ret = $node->backup('testbackup1');
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl
index c55497d61a..15ace5f51c 100644
--- a/src/test/recovery/t/001_stream_rep.pl
+++ b/src/test/recovery/t/001_stream_rep.pl
@@ -156,7 +156,8 @@ sub wait_slot_xmins
SELECT $check_expr
FROM pg_catalog.pg_replication_slots
WHERE slot_name = '$slot_name';
- ]);
+ ])
+ or die "Timed out waiting for slot xmins to advance";
}
# Fetch xmin columns from slot's pg_replication_slots row
diff --git a/src/test/recovery/t/005_replay_delay.pl b/src/test/recovery/t/005_replay_delay.pl
index 94c49443a5..208b278fcd 100644
--- a/src/test/recovery/t/005_replay_delay.pl
+++ b/src/test/recovery/t/005_replay_delay.pl
@@ -44,23 +44,9 @@ $node_master->safe_psql('postgres',
my $until_lsn =
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()");
-my $remaining = 90;
-while ($remaining-- > 0)
-{
-
- # Done waiting?
- my $replay_status = $node_standby->safe_psql('postgres',
- "SELECT (pg_last_wal_replay_lsn() - '$until_lsn'::pg_lsn) >= 0");
- last if $replay_status eq 't';
-
- # No, sleep some more.
- my $sleep = $master_insert_time + $delay - time();
- $sleep = 1 if $sleep < 1;
- sleep $sleep;
-}
-
-die "Maximum number of attempts reached ($remaining remain)"
- if $remaining < 0;
+$node_standby->poll_query_until('postgres',
+ "SELECT (pg_last_wal_replay_lsn() - '$until_lsn'::pg_lsn) >= 0")
+ or die "standby never caught up";
# This test is successful if and only if the LSN has been applied with at least
# the configured apply delay.
diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl
index 72428be0bf..ea389ba463 100644
--- a/src/test/recovery/t/006_logical_decoding.pl
+++ b/src/test/recovery/t/006_logical_decoding.pl
@@ -111,9 +111,10 @@ SKIP:
'-S', 'otherdb_slot', '-f', '-', '--start' ]);
$node_master->poll_query_until('otherdb',
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NOT NULL)"
- );
+ )
+ or die "slot never became active";
is($node_master->psql('postgres', 'DROP DATABASE otherdb'),
- 3, 'dropping a DB with inactive logical slots fails');
+ 3, 'dropping a DB with active logical slots fails');
$pg_recvlogical->kill_kill;
is($node_master->slot('otherdb_slot')->{'slot_name'},
undef, 'logical slot still exists');
@@ -121,7 +122,9 @@ SKIP:
$node_master->poll_query_until('otherdb',
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NULL)"
-);
+)
+ or die "slot never became inactive";
+
is($node_master->psql('postgres', 'DROP DATABASE otherdb'),
0, 'dropping a DB with inactive logical slots succeeds');
is($node_master->slot('otherdb_slot')->{'slot_name'},
diff --git a/src/test/recovery/t/010_logical_decoding_timelines.pl b/src/test/recovery/t/010_logical_decoding_timelines.pl
index 65f6ba2fca..ed9e4997c4 100644
--- a/src/test/recovery/t/010_logical_decoding_timelines.pl
+++ b/src/test/recovery/t/010_logical_decoding_timelines.pl
@@ -117,7 +117,9 @@ $node_master->poll_query_until(
SELECT catalog_xmin IS NOT NULL
FROM pg_replication_slots
WHERE slot_name = 'phys_slot'
- ]);
+ ])
+ or die "slot's catalog_xmin never became set";
+
my $phys_slot = $node_master->slot('phys_slot');
isnt($phys_slot->{'xmin'}, '', 'xmin assigned on physical slot of master');
isnt($phys_slot->{'catalog_xmin'},
@@ -137,7 +139,8 @@ $node_master->stop('immediate');
$node_replica->promote;
print "waiting for replica to come up\n";
$node_replica->poll_query_until('postgres',
- "SELECT NOT pg_is_in_recovery();");
+ "SELECT NOT pg_is_in_recovery();")
+ or die "replica never exited recovery";
$node_replica->safe_psql('postgres',
"INSERT INTO decoding(blah) VALUES ('after failover');");