Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29ec94e

Browse files
committed
Introduce PG_TEST_TIMEOUT_DEFAULT for TAP suite non-elapsing timeouts.
Slow hosts may avoid load-induced, spurious failures by settingenvironment variable PG_TEST_TIMEOUT_DEFAULT to some number of secondsgreater than 180. Developers may see faster failures by setting thatenvironment variable to some lesser number of seconds. In tests, write$PostgreSQL::Test::Utils::timeout_default wherever the convention hasbeen to write 180. This change raises the default for some briefertimeouts. Back-patch to v10 (all supported versions).Discussion:https://postgr.es/m/20220218052842.GA3627003@rfd.leadboat.com
1 parent5939274 commit29ec94e

File tree

14 files changed

+53
-39
lines changed

14 files changed

+53
-39
lines changed

‎contrib/amcheck/t/002_cic.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#
1919
$node = get_new_node('CIC_test');
2020
$node->init;
21-
$node->append_conf('postgresql.conf','lock_timeout = 180000');
21+
$node->append_conf('postgresql.conf',
22+
'lock_timeout =' . (1000 *$TestLib::timeout_default));
2223
$node->start;
2324
$node->safe_psql('postgres',q(CREATE EXTENSION amcheck));
2425
$node->safe_psql('postgres',q(CREATE TABLE tbl(i int)));

‎contrib/amcheck/t/003_cic_2pc.pl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
$node = get_new_node('CIC_2PC_test');
2323
$node->init;
2424
$node->append_conf('postgresql.conf','max_prepared_transactions = 10');
25-
$node->append_conf('postgresql.conf','lock_timeout = 180000');
25+
$node->append_conf('postgresql.conf',
26+
'lock_timeout =' . (1000 *$TestLib::timeout_default));
2627
$node->start;
2728
$node->safe_psql('postgres',q(CREATE EXTENSION amcheck));
2829
$node->safe_psql('postgres',q(CREATE TABLE tbl(i int)));
@@ -38,7 +39,7 @@
3839

3940
my$main_in ='';
4041
my$main_out ='';
41-
my$main_timer = IPC::Run::timeout(180);
42+
my$main_timer = IPC::Run::timeout($TestLib::timeout_default);
4243

4344
my$main_h =
4445
$node->background_psql('postgres', \$main_in, \$main_out,
@@ -52,7 +53,7 @@
5253

5354
my$cic_in ='';
5455
my$cic_out ='';
55-
my$cic_timer = IPC::Run::timeout(180);
56+
my$cic_timer = IPC::Run::timeout($TestLib::timeout_default);
5657
my$cic_h =
5758
$node->background_psql('postgres', \$cic_in, \$cic_out,
5859
$cic_timer,on_error_stop=> 1);
@@ -113,9 +114,10 @@
113114
));
114115
$node->restart;
115116

116-
my$reindex_in ='';
117-
my$reindex_out ='';
118-
my$reindex_timer = IPC::Run::timeout(180);
117+
my$reindex_in ='';
118+
my$reindex_out ='';
119+
my$reindex_timer =
120+
IPC::Run::timeout($TestLib::timeout_default);
119121
my$reindex_h =
120122
$node->background_psql('postgres', \$reindex_in, \$reindex_out,
121123
$reindex_timer,on_error_stop=> 1);

‎src/bin/pg_ctl/t/004_logrotate.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$node->psql('postgres','SELECT 1/0');
2525

2626
# might need to retry if logging collector process is slow...
27-
my$max_attempts =180 *10;
27+
my$max_attempts =10 *$TestLib::timeout_default;
2828

2929
my$current_logfiles;
3030
for (my$attempts = 0;$attempts <$max_attempts;$attempts++)

‎src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@
271271
'--no-sync',
272272
"--file=$tempdir/only_dump_test_table.sql",
273273
'--table=dump_test.test_table',
274-
'--lock-wait-timeout=1000000',
274+
'--lock-wait-timeout='
275+
. (1000 *$TestLib::timeout_default),
275276
'postgres',
276277
],
277278
},

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
my$in ='';
9090
my$out ='';
9191

92-
my$timer = timer(5);
92+
my$timer = timer($TestLib::timeout_default);
9393

9494
my$h =$node->interactive_psql('postgres', \$in, \$out,$timer);
9595

@@ -106,7 +106,7 @@ sub check_completion
106106
# reset output collector
107107
$out ="";
108108
# restart per-command timer
109-
$timer->start(5);
109+
$timer->start($TestLib::timeout_default);
110110
# send the data to be sent
111111
$in .=$send;
112112
# wait ...
@@ -232,7 +232,7 @@ sub clear_line
232232
clear_line();
233233

234234
# send psql an explicit \q to shut it down, else pty won't close properly
235-
$timer->start(5);
235+
$timer->start($TestLib::timeout_default);
236236
$in .="\\q\n";
237237
finish$hordie"psql returned$?";
238238
$timer->reset;

‎src/bin/scripts/t/080_pg_isready.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
$node->init;
1616
$node->start;
1717

18-
# use a long timeout for the benefit of very slow buildfarm machines
19-
$node->command_ok([qw(pg_isready--timeout=60)],
18+
$node->command_ok(
19+
['pg_isready',"--timeout=$TestLib::timeout_default"],
2020
'succeeds with server running');

‎src/test/perl/PostgresNode.pm

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ PostgresNode - class representing PostgreSQL server instance
3131
my ($stdout, $stderr, $timed_out);
3232
my $cmdret = $node->psql('postgres', 'SELECT pg_sleep(600)',
3333
stdout => \$stdout, stderr => \$stderr,
34-
timeout => 180, timed_out => \$timed_out,
34+
timeout => $TestLib::timeout_default,
35+
timed_out => \$timed_out,
3536
extra_params => ['--single-transaction'],
3637
on_error_die => 1)
3738
print "Sleep timed out" if $timed_out;
@@ -1446,7 +1447,8 @@ e.g.
14461447
my ($stdout, $stderr, $timed_out);
14471448
my $cmdret = $node->psql('postgres', 'SELECT pg_sleep(600)',
14481449
stdout => \$stdout, stderr => \$stderr,
1449-
timeout => 180, timed_out => \$timed_out,
1450+
timeout => $TestLib::timeout_default,
1451+
timed_out => \$timed_out,
14501452
extra_params => ['--single-transaction'])
14511453
14521454
will set $cmdret to undef and $timed_out to a true value.
@@ -1610,7 +1612,8 @@ scalar reference. This allows the caller to act on other parts of the system
16101612
while idling this backend.
16111613
16121614
The specified timer object is attached to the harness, as well. It's caller's
1613-
responsibility to select the timeout length, and to restart the timer after
1615+
responsibility to set the timeout length (usually
1616+
$TestLib::timeout_default), and to restart the timer after
16141617
each command if the timeout is per-command.
16151618
16161619
psql is invoked in tuples-only unaligned mode with reading ofB<.psqlrc>
@@ -1699,9 +1702,10 @@ The process's stdin is sourced from the $stdin scalar reference,
16991702
and its stdout and stderr go to the $stdout scalar reference.
17001703
ptys are used so that psql thinks it's being called interactively.
17011704
1702-
The specified timer object is attached to the harness, as well.
1703-
It's caller's responsibility to select the timeout length, and to
1704-
restart the timer after each command if the timeout is per-command.
1705+
The specified timer object is attached to the harness, as well. It's caller's
1706+
responsibility to set the timeout length (usually
1707+
$TestLib::timeout_default), and to restart the timer after
1708+
each command if the timeout is per-command.
17051709
17061710
psql is invoked in tuples-only unaligned mode with reading ofB<.psqlrc>
17071711
disabled. That may be overridden by passing extra psql parameters.
@@ -1849,7 +1853,7 @@ sub pgbench
18491853
RunB<$query> repeatedly, until it returns theB<$expected> result
18501854
('t', or SQL boolean true, by default).
18511855
Continues polling ifB<psql> returns an error result.
1852-
Times out after180 seconds.
1856+
Times out after$TestLib::timeout_default seconds.
18531857
Returns 1 if successful, 0 if timed out.
18541858
18551859
=cut
@@ -1862,7 +1866,7 @@ sub poll_query_until
18621866

18631867
my$cmd = ['psql','-XAt','-d',$self->connstr($dbname) ];
18641868
my ($stdout,$stderr);
1865-
my$max_attempts =180 *10;
1869+
my$max_attempts =10 *$TestLib::timeout_default;
18661870
my$attempts = 0;
18671871

18681872
while ($attempts <$max_attempts)
@@ -1884,8 +1888,8 @@ sub poll_query_until
18841888
$attempts++;
18851889
}
18861890

1887-
#The query result didn't change in 180 seconds. Give up. Print the
1888-
#output from the last attempt, hopefully that's usefulfor debugging.
1891+
#Give up. Print the output from the last attempt, hopefully that's useful
1892+
# for debugging.
18891893
diagqq(poll_query_until timed out executing this query:
18901894
$query
18911895
expecting this output:

‎src/test/perl/TestLib.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ our @EXPORT = qw(
8686
$use_unix_sockets
8787
);
8888

89-
our ($windows_os,$use_unix_sockets,$tmp_check,$log_path,$test_logfile);
89+
our ($windows_os,$use_unix_sockets,$timeout_default,
90+
$tmp_check,$log_path,$test_logfile);
9091

9192
BEGIN
9293
{
@@ -144,6 +145,10 @@ BEGIN
144145
# supported, but it can be overridden if desired.
145146
$use_unix_sockets =
146147
(!$windows_os ||defined$ENV{PG_TEST_USE_UNIX_SOCKETS});
148+
149+
$timeout_default =$ENV{PG_TEST_TIMEOUT_DEFAULT};
150+
$timeout_default = 180
151+
ifnotdefined$timeout_defaultor$timeout_defaulteq'';
147152
}
148153

149154
=pod

‎src/test/recovery/t/003_recovery_targets.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ sub test_recovery_standby
169169
$node_standby->logfile,'start'
170170
]);
171171

172-
# waitup to 180sfor postgres to terminate
173-
foreachmy$i (0 ..1800)
172+
# wait for postgres to terminate
173+
foreachmy$i (0 ..10 *$TestLib::timeout_default)
174174
{
175175
lastif !-f$node_standby->data_dir .'/postmaster.pid';
176176
usleep(100_000);

‎src/test/recovery/t/006_logical_decoding.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
);
9696

9797
my$stdout_recv =$node_master->pg_recvlogical_upto(
98-
'postgres','test_slot',$endpos,180,
98+
'postgres','test_slot',$endpos,$TestLib::timeout_default,
9999
'include-xids'=>'0',
100100
'skip-empty-xacts'=>'1');
101101
chomp($stdout_recv);
@@ -107,7 +107,7 @@
107107
)ordie"slot never became inactive";
108108

109109
$stdout_recv =$node_master->pg_recvlogical_upto(
110-
'postgres','test_slot',$endpos,180,
110+
'postgres','test_slot',$endpos,$TestLib::timeout_default,
111111
'include-xids'=>'0',
112112
'skip-empty-xacts'=>'1');
113113
chomp($stdout_recv);

‎src/test/recovery/t/010_logical_decoding_timelines.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
($ret,$stdout,$stderr) =$node_replica->psql(
156156
'postgres',
157157
"SELECT data FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');",
158-
timeout=>180);
158+
timeout=>$TestLib::timeout_default);
159159
is($ret, 0,'replay from slot before_basebackup succeeds');
160160

161161
my$final_expected_output_bb =q(BEGIN
@@ -184,7 +184,7 @@ BEGIN
184184

185185
$stdout =$node_replica->pg_recvlogical_upto(
186186
'postgres','before_basebackup',
187-
$endpos,180,
187+
$endpos,$TestLib::timeout_default,
188188
'include-xids'=>'0',
189189
'skip-empty-xacts'=>'1');
190190

‎src/test/recovery/t/013_crash_restart.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# instance being driven by us, add a timeout high enough that it
2424
# should never trigger even on very slow machines, unless something
2525
# is really wrong.
26-
my$psql_timeout = IPC::Run::timer(60);
26+
my$psql_timeout = IPC::Run::timer($TestLib::timeout_default);
2727

2828
my$node = get_new_node('master');
2929
$node->init(allows_streaming=> 1);

‎src/test/recovery/t/017_shm.pl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ sub log_ipcs
133133
\$stdout,
134134
'2>',
135135
\$stderr,
136-
IPC::Run::timeout(900));# five times the poll_query_until timeout
136+
IPC::Run::timeout(5 *$TestLib::timeout_default));
137137
ok($gnat->poll_query_until(
138138
'postgres',
139139
"SELECT 1 FROM pg_stat_activity WHERE query = '$slow_query'",'1'),
@@ -144,10 +144,11 @@ sub log_ipcs
144144
unlink($gnat->data_dir .'/postmaster.pid');
145145
$gnat->rotate_logfile;# on Windows, can't open old log for writing
146146
log_ipcs();
147-
# Reject ordinary startup. Retry for the same reasons poll_start() does.
147+
# Reject ordinary startup. Retry for the same reasons poll_start() does,
148+
# every 0.1s for at least $TestLib::timeout_default seconds.
148149
my$pre_existing_msg =qr/pre-existing shared memory block/;
149150
{
150-
my$max_attempts =180 *10;# Retry every 0.1s for at least 180s.
151+
my$max_attempts =10 *$TestLib::timeout_default;
151152
my$attempts = 0;
152153
while ($attempts <$max_attempts)
153154
{
@@ -194,7 +195,7 @@ sub poll_start
194195
{
195196
my ($node) =@_;
196197

197-
my$max_attempts =180 *10;
198+
my$max_attempts =10 *$TestLib::timeout_default;
198199
my$attempts = 0;
199200

200201
while ($attempts <$max_attempts)
@@ -210,8 +211,8 @@ sub poll_start
210211
$attempts++;
211212
}
212213

213-
#No success within 180 seconds.Try one last time without fail_ok, which
214-
#will BAIL_OUT unless itsucceeds.
214+
# Try one last time without fail_ok, which will BAIL_OUT unless it
215+
# succeeds.
215216
$node->start &&return 1;
216217
return 0;
217218
}

‎src/test/recovery/t/019_replslot_limit.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
SELECT pg_switch_wal();
294294
CHECKPOINT;
295295
SELECT 'finished';",
296-
timeout=>'60'));
296+
timeout=>$TestLib::timeout_default));
297297
is($result[1],'finished','check if checkpoint command is not blocked');
298298

299299
#####################################

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp