|
27 | 27 | plan tests => 12; |
28 | 28 | } |
29 | 29 |
|
| 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 | + |
30 | 36 | my $node = get_new_node('master'); |
31 | 37 | $node->init(allows_streaming => 1); |
32 | 38 | $node->start(); |
|
47 | 53 | '>', |
48 | 54 | \$killme_stdout, |
49 | 55 | '2>', |
50 | | - \$killme_stderr); |
| 56 | + \$killme_stderr, |
| 57 | + IPC::Run::timeout($psql_timeout)); |
51 | 58 |
|
52 | 59 | # Need a second psql to check if crash-restart happened. |
53 | 60 | my ($monitor_stdin, $monitor_stdout, $monitor_stderr) = ('', '', ''); |
|
59 | 66 | '>', |
60 | 67 | \$monitor_stdout, |
61 | 68 | '2>', |
62 | | - \$monitor_stderr); |
| 69 | + \$monitor_stderr, |
| 70 | + IPC::Run::timeout($psql_timeout)); |
63 | 71 |
|
64 | 72 | #create table, insert row that should survive |
65 | 73 | $killme_stdin .= q[ |
|
82 | 90 |
|
83 | 91 |
|
84 | 92 | # 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. |
86 | 95 | $monitor_stdin .= q[ |
| 96 | +SELECT $$psql-connected$$; |
87 | 97 | SELECT pg_sleep(3600); |
88 | 98 | ]; |
89 | | -$monitor->pump; |
| 99 | +$monitor->pump until $monitor_stdout =~ /psql-connected/; |
90 | 100 |
|
91 | 101 |
|
92 | 102 | # kill once with QUIT - we expect psql to exit, while emitting error message first |
|
137 | 147 | $killme->pump until $killme_stdout =~ /in-progress-before-sigkill/; |
138 | 148 | $killme_stdout = ''; |
139 | 149 |
|
140 | | -$monitor_stdin .= q[ |
141 | | -SELECT $$restart$$; |
142 | | -]; |
143 | | -$monitor->pump until $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. |
148 | 154 | $monitor_stdin = q[ |
| 155 | +SELECT $$psql-connected$$; |
149 | 156 | SELECT pg_sleep(3600); |
150 | 157 | ]; |
151 | | -$monitor->pump_nb; # don't wait for query results to come back |
| 158 | +$monitor->pump until $monitor_stdout =~ /psql-connected/; |
| 159 | +$monitor_stdout = ''; |
152 | 160 |
|
153 | 161 |
|
154 | 162 | # kill with SIGKILL this time - we expect the backend to exit, without |
|
0 commit comments