Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1ee4ba0

Browse files
author
Commitfest Bot
committed
[CF 4959] v4 - Fix BackgroundPsql to report error on query timeout rather than calling die
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/4959 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/73CC6454-E4DE-40D3-94FD-ECEBCE9236C6@yesql.se Author(s): Daniel Gustafsson
2 parents 05883bd + f1ce8d6 commit 1ee4ba0

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/bin/psql/t/010_tab_completion.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@
7777
# for possible debugging purposes.
7878
my $historyfile = "${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt";
7979

80-
# fire up an interactive psql session
80+
# fire up an interactive psql session and configure it such that each query
81+
# restarts the timer
8182
my $h = $node->interactive_psql('postgres', history_file => $historyfile);
83+
$h->set_query_timer_restart();
8284

8385
# Simple test case: type something and see if psql responds as expected
8486
sub check_completion
@@ -88,9 +90,6 @@ sub check_completion
8890
# report test failures from caller location
8991
local $Test::Builder::Level = $Test::Builder::Level + 1;
9092

91-
# restart per-command timer
92-
$h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default);
93-
9493
# send the data to be sent and wait for its result
9594
my $out = $h->query_until($pattern, $send);
9695
my $okay = ($out =~ $pattern && !$h->{timeout}->is_expired);

src/test/modules/test_misc/t/005_timeouts.pl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@
118118

119119
# We just initialize the GUC and wait. No transaction is required.
120120
$psql_session = $node->background_psql('postgres');
121-
$psql_session->query_until(
122-
qr/starting_bg_psql/, q(
123-
\echo starting_bg_psql
124-
SET idle_session_timeout to '10ms';
125-
));
121+
$psql_session->query(q(SET idle_session_timeout to '10ms';));
126122

127123
# Wait until the backend enters the timeout injection point.
128124
$node->wait_for_event('client backend', 'idle-session-timeout');

src/test/perl/PostgreSQL/Test/BackgroundPsql.pm

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ sub new
100100
"Forbidden caller of constructor: package: $package, file: $file:$line"
101101
unless $package->isa('PostgreSQL::Test::Cluster');
102102

103-
$psql->{timeout} = IPC::Run::timeout(
103+
$psql->{timeout} = IPC::Run::timer(
104104
defined($timeout)
105105
? $timeout
106106
: $PostgreSQL::Test::Utils::timeout_default);
@@ -179,8 +179,10 @@ sub wait_connect
179179
180180
=item $session->quit
181181
182-
Close the session and clean up resources. Each test run must be closed with
183-
C<quit>.
182+
Close the psql session and clean up resources. Each psql session must be
183+
closed with C<quit> before the end of the test. Returns TRUE if psql exited
184+
successfully (i.e. with zero exit code), otherwise returns FALSE and reports
185+
a test failure.
184186
185187
=cut
186188

@@ -190,7 +192,9 @@ sub quit
190192

191193
$self->{stdin} .= "\\q\n";
192194

193-
return $self->{run}->finish;
195+
my $ret = $self->{run}->finish;
196+
ok($ret, 'Terminating interactive psql session');
197+
return $ret;
194198
}
195199

196200
=pod
@@ -274,7 +278,8 @@ sub query
274278
$self->{run}, $self->{timeout},
275279
\$self->{stderr}, qr/$banner_match/);
276280

277-
die "psql query timed out" if $self->{timeout}->is_expired;
281+
ok(!$self->{timeout}->is_expired, 'psql query timed out') || return;
282+
$output = $self->{stdout};
278283

279284
note "results query $query_cnt:\n",
280285
explain {
@@ -342,7 +347,8 @@ sub query_until
342347

343348
pump_until($self->{run}, $self->{timeout}, \$self->{stdout}, $until);
344349

345-
die "psql query timed out" if $self->{timeout}->is_expired;
350+
ok(!$self->{timeout}->is_expired, 'psql query_until did not time out')
351+
|| return;
346352

347353
$ret = $self->{stdout};
348354

src/test/recovery/t/031_recovery_conflict.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
-- wait for lock held by prepared transaction
254254
SELECT * FROM $table2;
255255
]);
256-
ok(1,
256+
isnt($res, undef,
257257
"$sect: cursor holding conflicting pin, also waiting for lock, established"
258258
);
259259

0 commit comments

Comments
 (0)