Skip to content

Commit d3676a2

Browse files
committed
Close psql processes gracefully in recovery tests
Under windows, psql processes need to be ended explicitly, or the TAP tests hang. However, the recovery tests were doing this via IPC::Run::kill_kill(), which causes other major problems on Windows. We solve this by instead sending '\q' to psql so it quits of its own accord, and then simply waiting for it. This means we can now run almost all the recovery tests on all Windows platforms. Discussion: https://postgr.es/m/20210301200715.tdjpuesfzebpffgn@alap3.anarazel.de
1 parent 040af77 commit d3676a2

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/test/recovery/t/011_crash_recovery.pl

+3-10
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@
77
use TestLib;
88
use Test::More;
99
use Config;
10-
if ($Config{osname} eq 'MSWin32')
11-
{
1210

13-
# some Windows Perls at least don't like IPC::Run's start/kill_kill regime.
14-
plan skip_all => "Test fails on Windows perl";
15-
}
16-
else
17-
{
18-
plan tests => 3;
19-
}
11+
plan tests => 3;
2012

2113
my $node = get_new_node('primary');
2214
$node->init(allows_streaming => 1);
@@ -65,4 +57,5 @@
6557
is($node->safe_psql('postgres', qq[SELECT pg_xact_status('$xid');]),
6658
'aborted', 'xid is aborted after crash');
6759

68-
$tx->kill_kill;
60+
$stdin .= "\\q\n";
61+
$tx->finish; # wait for psql to quit gracefully

src/test/recovery/t/021_row_visibility.pl

+6-3
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,12 @@
151151
qr/will_commit.*\n\(1 row\)$/m),
152152
'finished prepared visible');
153153

154-
# explicitly shut down psql instances - they cause hangs on windows
155-
$psql_primary{run}->kill_kill;
156-
$psql_standby{run}->kill_kill;
154+
# explicitly shut down psql instances gracefully - to avoid hangs
155+
# or worse on windows
156+
$psql_primary{stdin} .= "\\q\n";
157+
$psql_primary{run}->finish;
158+
$psql_standby{stdin} .= "\\q\n";
159+
$psql_standby{run}->finish;
157160

158161
$node_primary->stop;
159162
$node_standby->stop;

0 commit comments

Comments
 (0)