diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2021-03-04 13:13:10 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2021-03-04 13:23:41 -0500 |
commit | d3676a2e9f10a0972c6d6649235c1c7492cd6dea (patch) | |
tree | 722f808bed70c440fb60063a7b3465d0770c756c /src | |
parent | 040af779382e8e4797242c49b93a5a8f9b79c370 (diff) | |
download | postgresql-d3676a2e9f10a0972c6d6649235c1c7492cd6dea.tar.gz postgresql-d3676a2e9f10a0972c6d6649235c1c7492cd6dea.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/test/recovery/t/011_crash_recovery.pl | 13 | ||||
-rw-r--r-- | src/test/recovery/t/021_row_visibility.pl | 9 |
2 files changed, 9 insertions, 13 deletions
diff --git a/src/test/recovery/t/011_crash_recovery.pl b/src/test/recovery/t/011_crash_recovery.pl index 5fe917978c6..10cd98f70aa 100644 --- a/src/test/recovery/t/011_crash_recovery.pl +++ b/src/test/recovery/t/011_crash_recovery.pl @@ -7,16 +7,8 @@ use PostgresNode; use TestLib; use Test::More; use Config; -if ($Config{osname} eq 'MSWin32') -{ - # some Windows Perls at least don't like IPC::Run's start/kill_kill regime. - plan skip_all => "Test fails on Windows perl"; -} -else -{ - plan tests => 3; -} +plan tests => 3; my $node = get_new_node('primary'); $node->init(allows_streaming => 1); @@ -65,4 +57,5 @@ cmp_ok($node->safe_psql('postgres', 'SELECT pg_current_xact_id()'), is($node->safe_psql('postgres', qq[SELECT pg_xact_status('$xid');]), 'aborted', 'xid is aborted after crash'); -$tx->kill_kill; +$stdin .= "\\q\n"; +$tx->finish; # wait for psql to quit gracefully diff --git a/src/test/recovery/t/021_row_visibility.pl b/src/test/recovery/t/021_row_visibility.pl index b76990dfe05..f6a486bb886 100644 --- a/src/test/recovery/t/021_row_visibility.pl +++ b/src/test/recovery/t/021_row_visibility.pl @@ -151,9 +151,12 @@ ok(send_query_and_wait(\%psql_standby, qr/will_commit.*\n\(1 row\)$/m), 'finished prepared visible'); -# explicitly shut down psql instances - they cause hangs on windows -$psql_primary{run}->kill_kill; -$psql_standby{run}->kill_kill; +# explicitly shut down psql instances gracefully - to avoid hangs +# or worse on windows +$psql_primary{stdin} .= "\\q\n"; +$psql_primary{run}->finish; +$psql_standby{stdin} .= "\\q\n"; +$psql_standby{run}->finish; $node_primary->stop; $node_standby->stop; |