Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1910353

Browse files
committed
Make new crash restart test a bit more robust.
Add timeouts in case psql doesn't deliver the expected output, and tryto cause the monitoring psql to be fully connected to a backend. Thisisn't necessarily everything needed, but at least the timeouts shouldreduce the pain for buildfarm owners.Author: Andres FreundReported-By: Tom Lane, BF animals prairiedog and calliphoridaeDiscussion:https://postgr.es/m/E1du6ZT-00043I-91@gemulon.postgresql.org
1 parentd61f5bb commit1910353

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

‎src/test/recovery/t/013_crash_restart.pl

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
plantests=> 12;
2828
}
2929

30+
# To avoid hanging while expecting some specific input from a psql
31+
# instance being driven by us, add a timeout high enough that it
32+
# should never trigger in a normal run, but low enough to actually see
33+
# failures in a realistic amount of time.
34+
my$psql_timeout = 180;
35+
3036
my$node = get_new_node('master');
3137
$node->init(allows_streaming=> 1);
3238
$node->start();
@@ -47,7 +53,8 @@
4753
'>',
4854
\$killme_stdout,
4955
'2>',
50-
\$killme_stderr);
56+
\$killme_stderr,
57+
IPC::Run::timeout($psql_timeout));
5158

5259
# Need a second psql to check if crash-restart happened.
5360
my ($monitor_stdin,$monitor_stdout,$monitor_stderr) = ('','','');
@@ -59,7 +66,8 @@
5966
'>',
6067
\$monitor_stdout,
6168
'2>',
62-
\$monitor_stderr);
69+
\$monitor_stderr,
70+
IPC::Run::timeout($psql_timeout));
6371

6472
#create table, insert row that should survive
6573
$killme_stdin .=q[
@@ -82,11 +90,13 @@
8290

8391

8492
# Start longrunning query in second session, it's failure will signal
85-
# that crash-restart has occurred.
93+
# that crash-restart has occurred. The initial wait for the trivial
94+
# select is to be sure that psql successfully connected to backend.
8695
$monitor_stdin .=q[
96+
SELECT $$psql-connected$$;
8797
SELECT pg_sleep(3600);
8898
];
89-
$monitor->pump;
99+
$monitor->pumpuntil$monitor_stdout =~/psql-connected/;
90100

91101

92102
# kill once with QUIT - we expect psql to exit, while emitting error message first
@@ -137,18 +147,16 @@
137147
$killme->pumpuntil$killme_stdout =~/in-progress-before-sigkill/;
138148
$killme_stdout ='';
139149

140-
$monitor_stdin .=q[
141-
SELECT $$restart$$;
142-
];
143-
$monitor->pumpuntil$monitor_stdout =~/restart/;
144-
$monitor_stdout ='';
145-
146-
# Re-start longrunning query in second session, it's failure will signal
147-
# that crash-restart has occurred.
150+
# Re-start longrunning query in second session, it's failure will
151+
# signal that crash-restart has occurred. The initial wait for the
152+
# trivial select is to be sure that psql successfully connected to
153+
# backend.
148154
$monitor_stdin =q[
155+
SELECT $$psql-connected$$;
149156
SELECT pg_sleep(3600);
150157
];
151-
$monitor->pump_nb;# don't wait for query results to come back
158+
$monitor->pumpuntil$monitor_stdout =~/psql-connected/;
159+
$monitor_stdout ='';
152160

153161

154162
# kill with SIGKILL this time - we expect the backend to exit, without

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp