mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-07-18 13:11:10 +02:00
Backpatch addition of pump_until() more completely.
Ina2ab9c06ea
I just backpatched the introduction of pump_until(), without changing the existing local definitions (as6da65a3f9a
). 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 beforef74496dd61
(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
This commit is contained in:
parent
e9735d1af1
commit
6ab90d215a
@ -72,7 +72,7 @@ CREATE TABLE alive(status text);
|
|||||||
INSERT INTO alive VALUES($$committed-before-sigquit$$);
|
INSERT INTO alive VALUES($$committed-before-sigquit$$);
|
||||||
SELECT pg_backend_pid();
|
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');
|
'acquired pid for SIGQUIT');
|
||||||
my $pid = $killme_stdout;
|
my $pid = $killme_stdout;
|
||||||
chomp($pid);
|
chomp($pid);
|
||||||
@ -84,7 +84,7 @@ $killme_stdin .= q[
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO alive VALUES($$in-progress-before-sigquit$$) RETURNING status;
|
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');
|
'inserted in-progress-before-sigquit');
|
||||||
$killme_stdout = '';
|
$killme_stdout = '';
|
||||||
$killme_stderr = '';
|
$killme_stderr = '';
|
||||||
@ -97,7 +97,7 @@ $monitor_stdin .= q[
|
|||||||
SELECT $$psql-connected$$;
|
SELECT $$psql-connected$$;
|
||||||
SELECT pg_sleep(3600);
|
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 connected');
|
||||||
$monitor_stdout = '';
|
$monitor_stdout = '';
|
||||||
$monitor_stderr = '';
|
$monitor_stderr = '';
|
||||||
@ -114,6 +114,7 @@ SELECT 1;
|
|||||||
];
|
];
|
||||||
ok( pump_until(
|
ok( pump_until(
|
||||||
$killme,
|
$killme,
|
||||||
|
$psql_timeout,
|
||||||
\$killme_stderr,
|
\$killme_stderr,
|
||||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly|connection to server was lost/m
|
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.
|
# sending.
|
||||||
ok( pump_until(
|
ok( pump_until(
|
||||||
$monitor,
|
$monitor,
|
||||||
|
$psql_timeout,
|
||||||
\$monitor_stderr,
|
\$monitor_stderr,
|
||||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly|connection to server was lost/m
|
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[
|
$killme_stdin .= q[
|
||||||
SELECT pg_backend_pid();
|
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");
|
"acquired pid for SIGKILL");
|
||||||
$pid = $killme_stdout;
|
$pid = $killme_stdout;
|
||||||
chomp($pid);
|
chomp($pid);
|
||||||
@ -162,7 +164,7 @@ INSERT INTO alive VALUES($$committed-before-sigkill$$) RETURNING status;
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO alive VALUES($$in-progress-before-sigkill$$) RETURNING status;
|
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');
|
'inserted in-progress-before-sigkill');
|
||||||
$killme_stdout = '';
|
$killme_stdout = '';
|
||||||
$killme_stderr = '';
|
$killme_stderr = '';
|
||||||
@ -174,7 +176,7 @@ $monitor_stdin .= q[
|
|||||||
SELECT $$psql-connected$$;
|
SELECT $$psql-connected$$;
|
||||||
SELECT pg_sleep(3600);
|
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 connected');
|
||||||
$monitor_stdout = '';
|
$monitor_stdout = '';
|
||||||
$monitor_stderr = '';
|
$monitor_stderr = '';
|
||||||
@ -192,6 +194,7 @@ SELECT 1;
|
|||||||
];
|
];
|
||||||
ok( pump_until(
|
ok( pump_until(
|
||||||
$killme,
|
$killme,
|
||||||
|
$psql_timeout,
|
||||||
\$killme_stderr,
|
\$killme_stderr,
|
||||||
qr/server closed the connection unexpectedly|connection to server was lost/m
|
qr/server closed the connection unexpectedly|connection to server was lost/m
|
||||||
),
|
),
|
||||||
@ -203,6 +206,7 @@ $killme->finish;
|
|||||||
# sending.
|
# sending.
|
||||||
ok( pump_until(
|
ok( pump_until(
|
||||||
$monitor,
|
$monitor,
|
||||||
|
$psql_timeout,
|
||||||
\$monitor_stderr,
|
\$monitor_stderr,
|
||||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly|connection to server was lost/m
|
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');
|
'can still write after orderly restart');
|
||||||
|
|
||||||
$node->stop();
|
$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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user