$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',
# 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');
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
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.
'-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');
$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'},
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'},
$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');");