diff options
| author | Amit Kapila | 2019-11-30 02:13:42 +0000 |
|---|---|---|
| committer | Amit Kapila | 2019-11-30 02:31:20 +0000 |
| commit | 98a9b37ba70f24b28478360d9cf7f190b0f75f8d (patch) | |
| tree | b33de5d6005243f19616cb11ac8d99cb922d8187 /src/test | |
| parent | e6c2d17c5367ddcd900450c6a857dac8630da0ca (diff) | |
Revert commits 290acac92b and 8a7e9e9dad.
This commit revert the commits to add a test case that tests the 'force'
option when there is an active backend connected to the database being
dropped.
This feature internally sends SIGTERM to all the backends connected to the
database being dropped and then the same is reported to the client. We
found that on Windows, the client end of the socket is not able to read
the data once we close the socket in the server which leads to loss of
error message which is not what we expect. We also observed similar
behavior in other cases like pg_terminate_backend(),
pg_ctl kill TERM <pid>. There are probably a few others like that. The
fix for this requires further study.
Discussion: https://postgr.es/m/E1iaD8h-0004us-K9@gemulon.postgresql.org
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/perl/TestLib.pm | 37 | ||||
| -rw-r--r-- | src/test/recovery/t/013_crash_restart.pl | 63 |
2 files changed, 40 insertions, 60 deletions
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index c0e636cfa1d..458b8013796 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -860,43 +860,6 @@ sub command_checks_all =pod -=item pump_until(proc, timeout, stream, untl) - -# Pump until string is matched, or timeout occurs - -=cut - -sub pump_until -{ - my ($proc, $timeout, $stream, $untl) = @_; - $proc->pump_nb(); - while (1) - { - last if $$stream =~ /$untl/; - if ($timeout->is_expired) - { - diag("aborting wait: program timed out"); - diag("stream contents: >>", $$stream, "<<"); - diag("pattern searched for: ", $untl); - - return 0; - } - if (not $proc->pumpable()) - { - diag("aborting wait: program died"); - diag("stream contents: >>", $$stream, "<<"); - diag("pattern searched for: ", $untl); - - return 0; - } - $proc->pump(); - } - return 1; - -} - -=pod - =back =cut diff --git a/src/test/recovery/t/013_crash_restart.pl b/src/test/recovery/t/013_crash_restart.pl index 595761949c9..2c477978e7d 100644 --- a/src/test/recovery/t/013_crash_restart.pl +++ b/src/test/recovery/t/013_crash_restart.pl @@ -72,9 +72,7 @@ CREATE TABLE alive(status text); INSERT INTO alive VALUES($$committed-before-sigquit$$); SELECT pg_backend_pid(); ]; -ok(TestLib::pump_until( - $killme, $psql_timeout, \$killme_stdout, - qr/[[:digit:]]+[\r\n]$/m), +ok(pump_until($killme, \$killme_stdout, qr/[[:digit:]]+[\r\n]$/m), 'acquired pid for SIGQUIT'); my $pid = $killme_stdout; chomp($pid); @@ -86,9 +84,7 @@ $killme_stdin .= q[ BEGIN; INSERT INTO alive VALUES($$in-progress-before-sigquit$$) RETURNING status; ]; -ok(TestLib::pump_until( - $killme, $psql_timeout, \$killme_stdout, - qr/in-progress-before-sigquit/m), +ok(pump_until($killme, \$killme_stdout, qr/in-progress-before-sigquit/m), 'inserted in-progress-before-sigquit'); $killme_stdout = ''; $killme_stderr = ''; @@ -101,8 +97,7 @@ $monitor_stdin .= q[ SELECT $$psql-connected$$; SELECT pg_sleep(3600); ]; -ok(TestLib::pump_until( - $monitor, $psql_timeout, \$monitor_stdout, qr/psql-connected/m), +ok(pump_until($monitor, \$monitor_stdout, qr/psql-connected/m), 'monitor connected'); $monitor_stdout = ''; $monitor_stderr = ''; @@ -117,9 +112,8 @@ is($ret, 0, "killed process with SIGQUIT"); $killme_stdin .= q[ SELECT 1; ]; -ok( TestLib::pump_until( +ok( pump_until( $killme, - $psql_timeout, \$killme_stderr, qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly|connection to server was lost/m ), @@ -131,9 +125,8 @@ $killme->finish; # Wait till server restarts - we should get the WARNING here, but # sometimes the server is unable to send that, if interrupted while # sending. -ok( TestLib::pump_until( +ok( pump_until( $monitor, - $psql_timeout, \$monitor_stderr, qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly|connection to server was lost/m ), @@ -160,8 +153,7 @@ $monitor->run(); $killme_stdin .= q[ SELECT pg_backend_pid(); ]; -ok(TestLib::pump_until( - $killme, $psql_timeout, \$killme_stdout, qr/[[:digit:]]+[\r\n]$/m), +ok(pump_until($killme, \$killme_stdout, qr/[[:digit:]]+[\r\n]$/m), "acquired pid for SIGKILL"); $pid = $killme_stdout; chomp($pid); @@ -174,9 +166,7 @@ INSERT INTO alive VALUES($$committed-before-sigkill$$) RETURNING status; BEGIN; INSERT INTO alive VALUES($$in-progress-before-sigkill$$) RETURNING status; ]; -ok(TestLib::pump_until( - $killme, $psql_timeout, \$killme_stdout, - qr/in-progress-before-sigkill/m), +ok(pump_until($killme, \$killme_stdout, qr/in-progress-before-sigkill/m), 'inserted in-progress-before-sigkill'); $killme_stdout = ''; $killme_stderr = ''; @@ -188,8 +178,7 @@ $monitor_stdin .= q[ SELECT $$psql-connected$$; SELECT pg_sleep(3600); ]; -ok(TestLib::pump_until( - $monitor, $psql_timeout, \$monitor_stdout, qr/psql-connected/m), +ok(pump_until($monitor, \$monitor_stdout, qr/psql-connected/m), 'monitor connected'); $monitor_stdout = ''; $monitor_stderr = ''; @@ -205,9 +194,8 @@ is($ret, 0, "killed process with KILL"); $killme_stdin .= q[ SELECT 1; ]; -ok( TestLib::pump_until( +ok( pump_until( $killme, - $psql_timeout, \$killme_stderr, qr/server closed the connection unexpectedly|connection to server was lost/m ), @@ -217,9 +205,8 @@ $killme->finish; # Wait till server restarts - we should get the WARNING here, but # sometimes the server is unable to send that, if interrupted while # sending. -ok( TestLib::pump_until( +ok( pump_until( $monitor, - $psql_timeout, \$monitor_stderr, qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly|connection to server was lost/m ), @@ -257,3 +244,33 @@ is( $node->safe_psql( 'can still write after orderly restart'); $node->stop(); + +# Pump until string is matched, or timeout occurs +sub pump_until +{ + my ($proc, $stream, $untl) = @_; + $proc->pump_nb(); + while (1) + { + last if $$stream =~ /$untl/; + if ($psql_timeout->is_expired) + { + diag("aborting wait: program timed out"); + diag("stream contents: >>", $$stream, "<<"); + diag("pattern searched for: ", $untl); + + return 0; + } + if (not $proc->pumpable()) + { + diag("aborting wait: program died"); + diag("stream contents: >>", $$stream, "<<"); + diag("pattern searched for: ", $untl); + + return 0; + } + $proc->pump(); + } + return 1; + +} |
