Commit b0f069d9 authored by Tom Lane's avatar Tom Lane

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.
parent f32678c0
......@@ -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',
......
......@@ -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');
......
......@@ -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
......
......@@ -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.
......
......@@ -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'},
......
......@@ -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');");
......
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