Daniel Gustafsson <[email protected]> writes:
> [ v4 patches for better timeout handling ]
I got around to reviewing these finally. v4-0001 looks good, except
that there is now another copy of the same logic in 030_pager.pl
which should be fixed in the same way. Proposed revision to do that
attached.
I'm not very comfortable with v4-0002, specifically the decision
that sub query and sub query_until should now return undef instead
of dying. I think that next to no call sites will handle that well.
Also, as this stands both subs will fail to reset $self->{stdout},
pretty much guaranteeing that the next query will fail too.
(Although if psql is stuck, do we have any chance at all of
subsequent tests succeeding? Dying might be superior to spewing
a bunch of content-free follow-on failures.)
a1d7ae2b2 already made what I think is the critical debuggability
improvement in sub query, namely to not die until after reporting
whatever we got from the query. I'm inclined to suggest that
sub query_until should be made to print a similar report, but
still die on timeout.
regards, tom lane
From 6abdea6c16617312cc3ecfd12342146924b75b8d Mon Sep 17 00:00:00 2001
From: Tom Lane <[email protected]>
Date: Wed, 11 Feb 2026 14:55:04 -0500
Subject: [PATCH v5] Restart BackgroundPsql's timer more nicely.
Use BackgroundPsql's published API for automatically restarting
its timer for each query, rather than manually reaching into it
to achieve the same thing.
010_tab_completion.pl's logic for this predates the invention
of BackgroundPsql (and 664d75753 missed the opportunity to
make it cleaner). 030_pager.pl copied-and-pasted the code.
Author: Daniel Gustafsson <[email protected]>
Reviewed-by: Heikki Linnakangas <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]
---
src/bin/psql/t/010_tab_completion.pl | 7 +++----
src/bin/psql/t/030_pager.pl | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl
index 7104aba2394..1d2e5f5b92a 100644
--- a/src/bin/psql/t/010_tab_completion.pl
+++ b/src/bin/psql/t/010_tab_completion.pl
@@ -77,8 +77,10 @@ close $FH;
# for possible debugging purposes.
my $historyfile = "${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt";
-# fire up an interactive psql session
+# fire up an interactive psql session and configure it such that each query
+# restarts the timer
my $h = $node->interactive_psql('postgres', history_file => $historyfile);
+$h->set_query_timer_restart();
# Simple test case: type something and see if psql responds as expected
sub check_completion
@@ -88,9 +90,6 @@ sub check_completion
# report test failures from caller location
local $Test::Builder::Level = $Test::Builder::Level + 1;
- # restart per-command timer
- $h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default);
-
# send the data to be sent and wait for its result
my $out = $h->query_until($pattern, $send);
my $okay = ($out =~ $pattern && !$h->{timeout}->is_expired);
diff --git a/src/bin/psql/t/030_pager.pl b/src/bin/psql/t/030_pager.pl
index a35f2b26293..d3f964639d3 100644
--- a/src/bin/psql/t/030_pager.pl
+++ b/src/bin/psql/t/030_pager.pl
@@ -70,8 +70,10 @@ $node->safe_psql(
25 as y,
26 as z');
-# fire up an interactive psql session
+# fire up an interactive psql session and configure it such that each query
+# restarts the timer
my $h = $node->interactive_psql('postgres');
+$h->set_query_timer_restart();
# set the pty's window size to known values
# (requires undesirable chumminess with the innards of IPC::Run)
@@ -88,9 +90,6 @@ sub do_command
# report test failures from caller location
local $Test::Builder::Level = $Test::Builder::Level + 1;
- # restart per-command timer
- $h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default);
-
# send the data to be sent and wait for its result
my $out = $h->query_until($pattern, $send);
my $okay = ($out =~ $pattern && !$h->{timeout}->is_expired);
--
2.43.7