Skip to content

Commit 85b98b8

Browse files
committed
Minor cleanup related to pg_wal_replay_wait() procedure
* Rename $node_standby1 to $node_standby in 043_wal_replay_wait.pl as there is only one standby. * Remove useless debug printing in 043_wal_replay_wait.pl. * Fix typo in one check description in 043_wal_replay_wait.pl. * Fix some wording in comments and documentation. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/1d7b08f2-64a2-77fb-c666-c9a74c68eeda%40gmail.com Reviewed-by: Alexander Lakhin
1 parent d8adfc1 commit 85b98b8

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

doc/src/sgml/func.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29076,7 +29076,7 @@ postgres=# SELECT * FROM movie WHERE genre = 'Drama';
2907629076
(0 rows)
2907729077
</programlisting>
2907829078

29079-
It may also happen that target <acronym>lsn</acronym> is not achieved
29079+
It may also happen that target <acronym>lsn</acronym> is not reached
2908029080
within the timeout. In that case the error is thrown.
2908129081

2908229082
<programlisting>

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6168,7 +6168,7 @@ StartupXLOG(void)
61686168

61696169
/*
61706170
* Wake up all waiters for replay LSN. They need to report an error that
6171-
* recovery was ended before achieving the target LSN.
6171+
* recovery was ended before reaching the target LSN.
61726172
*/
61736173
WaitLSNSetLatches(InvalidXLogRecPtr);
61746174

src/backend/commands/waitlsn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ WaitForLSNReplay(XLogRecPtr targetLSN, int64 timeout)
299299
/*
300300
* If the timeout value is specified, calculate the number of
301301
* milliseconds before the timeout. Exit if the timeout is already
302-
* achieved.
302+
* reached.
303303
*/
304304
if (timeout > 0)
305305
{
@@ -325,7 +325,7 @@ WaitForLSNReplay(XLogRecPtr targetLSN, int64 timeout)
325325
deleteLSNWaiter();
326326

327327
/*
328-
* If we didn't achieve the target LSN, we must be exited by timeout.
328+
* If we didn't reach the target LSN, we must be exited by timeout.
329329
*/
330330
if (targetLSN > currentLSN)
331331
{

src/test/recovery/t/043_wal_replay_wait.pl

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
$node_primary->backup($backup_name);
2020

2121
# Create a streaming standby with a 1 second delay from the backup
22-
my $node_standby1 = PostgreSQL::Test::Cluster->new('standby');
22+
my $node_standby = PostgreSQL::Test::Cluster->new('standby');
2323
my $delay = 1;
24-
$node_standby1->init_from_backup($node_primary, $backup_name,
24+
$node_standby->init_from_backup($node_primary, $backup_name,
2525
has_streaming => 1);
26-
$node_standby1->append_conf(
26+
$node_standby->append_conf(
2727
'postgresql.conf', qq[
2828
recovery_min_apply_delay = '${delay}s'
2929
]);
30-
$node_standby1->start;
30+
$node_standby->start;
3131

3232
# 1. Make sure that pg_wal_replay_wait() works: add new content to
3333
# primary and memorize primary's insert LSN, then wait for that LSN to be
@@ -36,7 +36,7 @@
3636
"INSERT INTO wait_test VALUES (generate_series(11, 20))");
3737
my $lsn1 =
3838
$node_primary->safe_psql('postgres', "SELECT pg_current_wal_insert_lsn()");
39-
my $output = $node_standby1->safe_psql(
39+
my $output = $node_standby->safe_psql(
4040
'postgres', qq[
4141
CALL pg_wal_replay_wait('${lsn1}', 1000000);
4242
SELECT pg_lsn_cmp(pg_last_wal_replay_lsn(), '${lsn1}'::pg_lsn);
@@ -52,7 +52,7 @@
5252
"INSERT INTO wait_test VALUES (generate_series(21, 30))");
5353
my $lsn2 =
5454
$node_primary->safe_psql('postgres', "SELECT pg_current_wal_insert_lsn()");
55-
$output = $node_standby1->safe_psql(
55+
$output = $node_standby->safe_psql(
5656
'postgres', qq[
5757
CALL pg_wal_replay_wait('${lsn2}');
5858
SELECT count(*) FROM wait_test;
@@ -68,9 +68,9 @@
6868
$node_primary->safe_psql('postgres',
6969
"SELECT pg_current_wal_insert_lsn() + 10000000000");
7070
my $stderr;
71-
$node_standby1->safe_psql('postgres',
71+
$node_standby->safe_psql('postgres',
7272
"CALL pg_wal_replay_wait('${lsn2}', 10);");
73-
$node_standby1->psql(
73+
$node_standby->psql(
7474
'postgres',
7575
"CALL pg_wal_replay_wait('${lsn3}', 1000);",
7676
stderr => \$stderr);
@@ -88,7 +88,7 @@
8888
ok( $stderr =~ /recovery is not in progress/,
8989
"get an error when running on the primary");
9090

91-
$node_standby1->psql(
91+
$node_standby->psql(
9292
'postgres',
9393
"BEGIN ISOLATION LEVEL REPEATABLE READ; CALL pg_wal_replay_wait('${lsn3}');",
9494
stderr => \$stderr);
@@ -107,8 +107,8 @@
107107
LANGUAGE plpgsql;
108108
]);
109109

110-
$node_primary->wait_for_catchup($node_standby1);
111-
$node_standby1->psql(
110+
$node_primary->wait_for_catchup($node_standby);
111+
$node_standby->psql(
112112
'postgres',
113113
"SELECT pg_wal_replay_wait_wrap('${lsn3}');",
114114
stderr => \$stderr);
@@ -134,29 +134,28 @@
134134
\$\$
135135
LANGUAGE plpgsql;
136136
]);
137-
$node_standby1->safe_psql('postgres', "SELECT pg_wal_replay_pause();");
137+
$node_standby->safe_psql('postgres', "SELECT pg_wal_replay_pause();");
138138
my @psql_sessions;
139139
for (my $i = 0; $i < 5; $i++)
140140
{
141-
print($i);
142141
$node_primary->safe_psql('postgres',
143142
"INSERT INTO wait_test VALUES (${i});");
144143
my $lsn =
145144
$node_primary->safe_psql('postgres',
146145
"SELECT pg_current_wal_insert_lsn()");
147-
$psql_sessions[$i] = $node_standby1->background_psql('postgres');
146+
$psql_sessions[$i] = $node_standby->background_psql('postgres');
148147
$psql_sessions[$i]->query_until(
149148
qr/start/, qq[
150149
\\echo start
151150
CALL pg_wal_replay_wait('${lsn}');
152151
SELECT log_count(${i});
153152
]);
154153
}
155-
my $log_offset = -s $node_standby1->logfile;
156-
$node_standby1->safe_psql('postgres', "SELECT pg_wal_replay_resume();");
154+
my $log_offset = -s $node_standby->logfile;
155+
$node_standby->safe_psql('postgres', "SELECT pg_wal_replay_resume();");
157156
for (my $i = 0; $i < 5; $i++)
158157
{
159-
$node_standby1->wait_for_log("count ${i}", $log_offset);
158+
$node_standby->wait_for_log("count ${i}", $log_offset);
160159
$psql_sessions[$i]->quit;
161160
}
162161

@@ -171,25 +170,24 @@
171170
"SELECT pg_current_wal_insert_lsn() + 10000000000");
172171
my $lsn5 =
173172
$node_primary->safe_psql('postgres', "SELECT pg_current_wal_insert_lsn()");
174-
my $psql_session = $node_standby1->background_psql('postgres');
173+
my $psql_session = $node_standby->background_psql('postgres');
175174
$psql_session->query_until(
176175
qr/start/, qq[
177176
\\echo start
178177
CALL pg_wal_replay_wait('${lsn4}');
179178
]);
180179

181-
$log_offset = -s $node_standby1->logfile;
182-
$node_standby1->promote;
183-
$node_standby1->wait_for_log('recovery is not in progress', $log_offset);
180+
$log_offset = -s $node_standby->logfile;
181+
$node_standby->promote;
182+
$node_standby->wait_for_log('recovery is not in progress', $log_offset);
184183

185184
ok(1, 'got error after standby promote');
186185

187-
$node_standby1->safe_psql('postgres', "CALL pg_wal_replay_wait('${lsn5}');");
186+
$node_standby->safe_psql('postgres', "CALL pg_wal_replay_wait('${lsn5}');");
188187

189-
ok(1,
190-
'wait for already replayed LSN exists immediately even after promotion');
188+
ok(1, 'wait for already replayed LSN exits immediately even after promotion');
191189

192-
$node_standby1->stop;
190+
$node_standby->stop;
193191
$node_primary->stop;
194192

195193
# If we send \q with $psql_session->quit the command can be sent to the session

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