Skip to content

Commit b0f069d

Browse files
committed
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.
1 parent f32678c commit b0f069d

File tree

6 files changed

+19
-25
lines changed

6 files changed

+19
-25
lines changed

src/test/modules/commit_ts/t/003_standby_2.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
$master->restart;
5656

5757
system_or_bail('pg_ctl', '-D', $standby->data_dir, 'promote');
58-
$standby->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true");
58+
$standby->poll_query_until('postgres', "SELECT NOT pg_is_in_recovery()")
59+
or die "standby never exited recovery";
5960

6061
$standby->safe_psql('postgres', "create table t11()");
6162
my $standby_ts = $standby->safe_psql('postgres',

src/test/perl/PostgresNode.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PostgresNode - class representing PostgreSQL server instance
4343
# run query every second until it returns 't'
4444
# or times out
4545
$node->poll_query_until('postgres', q|SELECT random() < 0.1;|')
46-
or print "timed out";
46+
or die "timed out";
4747
4848
# Do an online pg_basebackup
4949
my $ret = $node->backup('testbackup1');

src/test/recovery/t/001_stream_rep.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ sub wait_slot_xmins
156156
SELECT $check_expr
157157
FROM pg_catalog.pg_replication_slots
158158
WHERE slot_name = '$slot_name';
159-
]);
159+
])
160+
or die "Timed out waiting for slot xmins to advance";
160161
}
161162

162163
# Fetch xmin columns from slot's pg_replication_slots row

src/test/recovery/t/005_replay_delay.pl

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,9 @@
4444
my $until_lsn =
4545
$node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()");
4646

47-
my $remaining = 90;
48-
while ($remaining-- > 0)
49-
{
50-
51-
# Done waiting?
52-
my $replay_status = $node_standby->safe_psql('postgres',
53-
"SELECT (pg_last_wal_replay_lsn() - '$until_lsn'::pg_lsn) >= 0");
54-
last if $replay_status eq 't';
55-
56-
# No, sleep some more.
57-
my $sleep = $master_insert_time + $delay - time();
58-
$sleep = 1 if $sleep < 1;
59-
sleep $sleep;
60-
}
61-
62-
die "Maximum number of attempts reached ($remaining remain)"
63-
if $remaining < 0;
47+
$node_standby->poll_query_until('postgres',
48+
"SELECT (pg_last_wal_replay_lsn() - '$until_lsn'::pg_lsn) >= 0")
49+
or die "standby never caught up";
6450

6551
# This test is successful if and only if the LSN has been applied with at least
6652
# the configured apply delay.

src/test/recovery/t/006_logical_decoding.pl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,20 @@
111111
'-S', 'otherdb_slot', '-f', '-', '--start' ]);
112112
$node_master->poll_query_until('otherdb',
113113
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NOT NULL)"
114-
);
114+
)
115+
or die "slot never became active";
115116
is($node_master->psql('postgres', 'DROP DATABASE otherdb'),
116-
3, 'dropping a DB with inactive logical slots fails');
117+
3, 'dropping a DB with active logical slots fails');
117118
$pg_recvlogical->kill_kill;
118119
is($node_master->slot('otherdb_slot')->{'slot_name'},
119120
undef, 'logical slot still exists');
120121
}
121122

122123
$node_master->poll_query_until('otherdb',
123124
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NULL)"
124-
);
125+
)
126+
or die "slot never became inactive";
127+
125128
is($node_master->psql('postgres', 'DROP DATABASE otherdb'),
126129
0, 'dropping a DB with inactive logical slots succeeds');
127130
is($node_master->slot('otherdb_slot')->{'slot_name'},

src/test/recovery/t/010_logical_decoding_timelines.pl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@
117117
SELECT catalog_xmin IS NOT NULL
118118
FROM pg_replication_slots
119119
WHERE slot_name = 'phys_slot'
120-
]);
120+
])
121+
or die "slot's catalog_xmin never became set";
122+
121123
my $phys_slot = $node_master->slot('phys_slot');
122124
isnt($phys_slot->{'xmin'}, '', 'xmin assigned on physical slot of master');
123125
isnt($phys_slot->{'catalog_xmin'},
@@ -137,7 +139,8 @@
137139
$node_replica->promote;
138140
print "waiting for replica to come up\n";
139141
$node_replica->poll_query_until('postgres',
140-
"SELECT NOT pg_is_in_recovery();");
142+
"SELECT NOT pg_is_in_recovery();")
143+
or die "replica never exited recovery";
141144

142145
$node_replica->safe_psql('postgres',
143146
"INSERT INTO decoding(blah) VALUES ('after failover');");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy