On 3/3/21 7:21 PM, Andrew Dunstan wrote: > On 3/3/21 5:32 PM, Andrew Dunstan wrote: >> On 3/3/21 4:42 PM, Andres Freund wrote: >>> Hi, >>> >>> On 2021-03-03 16:07:13 -0500, Andrew Dunstan wrote: >>>> Here's what I actually got working. Rip out the calls to kill_kill and >>>> replace them with: >>>> >>>> >>>> $psql_primary{stdin} .= "\\q\n"; >>>> $psql_primary{run}->pump_nb(); >>>> $psql_standby{stdin} .= "\\q\n"; >>>> $psql_standby{run}->pump_nb(); >>>> sleep 2; # give them time to quit >>>> >>>> >>>> No hang or signal now. >>> Hm. I wonder if we can avoid the sleep 2 by doing something like >>> ->pump(); ->finish(); instead of one pump_nb()? One pump() is needed to >>> send the \q to psql, and then we need to wait for the process to finish? >>> I'll try that, but given that I can't reproduce any problems... >> Looking at the examples in the IPC:Run docco, it looks like we might >> just be able to replace the pump_nb above with finish, and leave the >> sleep out. I'll try that. > > OK, this worked fine. I'll try it s a recipe in the other places where > kill_kill is forcing us to skip tests under MSwin32 perl, and see how we go. > >
Here's the patch. I didn't see a convenient way of handling the pg_recvlogical case, so that's unchanged. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com
diff --git a/src/test/recovery/t/011_crash_recovery.pl b/src/test/recovery/t/011_crash_recovery.pl index 5fe917978c..10cd98f70a 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 b76990dfe0..f6a486bb88 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;