summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-05-06 08:39:11 -0700
committerAndres Freund <andres@anarazel.de>2022-05-06 08:39:11 -0700
commitfbf659bc40409be03758d9fe2535c82895dd5d45 (patch)
treefe6d5f8f06f3ea88eaab755d451c5f8b7cb632e8
parent2bb9f7501a6fa0c5db9c333ac0865a2abde8a76c (diff)
downloadpostgresql-fbf659bc40409be03758d9fe2535c82895dd5d45.tar.gz
Backpatch addition of pump_until() more completely.
In a2ab9c06ea1 I just backpatched the introduction of pump_until(), without changing the existing local definitions (as 6da65a3f9a9). The necessary changes seemed more verbose than desirable. However, that leads to warnings, as I failed to realize... Backpatch to all versions containing pump_until() calls before f74496dd611 (there's none in 10). Discussion: https://postgr.es/m/2808491.1651802860@sss.pgh.pa.us Discussion: https://postgr.es/m/18b37361-b482-b9d8-f30d-6115cd5ce25c@enterprisedb.com Backpatch: 11-14
-rw-r--r--src/test/recovery/t/013_crash_restart.pl46
1 files changed, 10 insertions, 36 deletions
diff --git a/src/test/recovery/t/013_crash_restart.pl b/src/test/recovery/t/013_crash_restart.pl
index 95445dc097..7aced79ca7 100644
--- a/src/test/recovery/t/013_crash_restart.pl
+++ b/src/test/recovery/t/013_crash_restart.pl
@@ -72,7 +72,7 @@ CREATE TABLE alive(status text);
INSERT INTO alive VALUES($$committed-before-sigquit$$);
SELECT pg_backend_pid();
];
-ok(pump_until($killme, \$killme_stdout, qr/[[:digit:]]+[\r\n]$/m),
+ok(pump_until($killme, $psql_timeout, \$killme_stdout, qr/[[:digit:]]+[\r\n]$/m),
'acquired pid for SIGQUIT');
my $pid = $killme_stdout;
chomp($pid);
@@ -84,7 +84,7 @@ $killme_stdin .= q[
BEGIN;
INSERT INTO alive VALUES($$in-progress-before-sigquit$$) RETURNING status;
];
-ok(pump_until($killme, \$killme_stdout, qr/in-progress-before-sigquit/m),
+ok(pump_until($killme, $psql_timeout, \$killme_stdout, qr/in-progress-before-sigquit/m),
'inserted in-progress-before-sigquit');
$killme_stdout = '';
$killme_stderr = '';
@@ -97,7 +97,7 @@ $monitor_stdin .= q[
SELECT $$psql-connected$$;
SELECT pg_sleep(3600);
];
-ok(pump_until($monitor, \$monitor_stdout, qr/psql-connected/m),
+ok(pump_until($monitor, $psql_timeout, \$monitor_stdout, qr/psql-connected/m),
'monitor connected');
$monitor_stdout = '';
$monitor_stderr = '';
@@ -114,6 +114,7 @@ SELECT 1;
];
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
),
@@ -127,6 +128,7 @@ $killme->finish;
# sending.
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
),
@@ -149,7 +151,7 @@ $monitor->run();
$killme_stdin .= q[
SELECT pg_backend_pid();
];
-ok(pump_until($killme, \$killme_stdout, qr/[[:digit:]]+[\r\n]$/m),
+ok(pump_until($killme, $psql_timeout, \$killme_stdout, qr/[[:digit:]]+[\r\n]$/m),
"acquired pid for SIGKILL");
$pid = $killme_stdout;
chomp($pid);
@@ -162,7 +164,7 @@ INSERT INTO alive VALUES($$committed-before-sigkill$$) RETURNING status;
BEGIN;
INSERT INTO alive VALUES($$in-progress-before-sigkill$$) RETURNING status;
];
-ok(pump_until($killme, \$killme_stdout, qr/in-progress-before-sigkill/m),
+ok(pump_until($killme, $psql_timeout, \$killme_stdout, qr/in-progress-before-sigkill/m),
'inserted in-progress-before-sigkill');
$killme_stdout = '';
$killme_stderr = '';
@@ -174,7 +176,7 @@ $monitor_stdin .= q[
SELECT $$psql-connected$$;
SELECT pg_sleep(3600);
];
-ok(pump_until($monitor, \$monitor_stdout, qr/psql-connected/m),
+ok(pump_until($monitor, $psql_timeout, \$monitor_stdout, qr/psql-connected/m),
'monitor connected');
$monitor_stdout = '';
$monitor_stderr = '';
@@ -192,6 +194,7 @@ SELECT 1;
];
ok( pump_until(
$killme,
+ $psql_timeout,
\$killme_stderr,
qr/server closed the connection unexpectedly|connection to server was lost/m
),
@@ -203,6 +206,7 @@ $killme->finish;
# sending.
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
),
@@ -240,33 +244,3 @@ 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;
-
-}