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

Commit8700a48

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 parent4b0696b commit8700a48

File tree

11 files changed

+42
-30
lines changed

11 files changed

+42
-30
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/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: 10 additions & 7 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;
@@ -1412,7 +1413,8 @@ e.g.
14121413
my ($stdout, $stderr, $timed_out);
14131414
my $cmdret = $node->psql('postgres', 'SELECT pg_sleep(600)',
14141415
stdout => \$stdout, stderr => \$stderr,
1415-
timeout => 180, timed_out => \$timed_out,
1416+
timeout => $TestLib::timeout_default,
1417+
timed_out => \$timed_out,
14161418
extra_params => ['--single-transaction'])
14171419
14181420
will set $cmdret to undef and $timed_out to a true value.
@@ -1569,7 +1571,8 @@ scalar reference. This allows the caller to act on other parts of the system
15691571
while idling this backend.
15701572
15711573
The specified timer object is attached to the harness, as well. It's caller's
1572-
responsibility to select the timeout length, and to restart the timer after
1574+
responsibility to set the timeout length (usually
1575+
$TestLib::timeout_default), and to restart the timer after
15731576
each command if the timeout is per-command.
15741577
15751578
psql is invoked in tuples-only unaligned mode with reading ofB<.psqlrc>
@@ -1741,7 +1744,7 @@ sub pgbench
17411744
RunB<$query> repeatedly, until it returns theB<$expected> result
17421745
('t', or SQL boolean true, by default).
17431746
Continues polling ifB<psql> returns an error result.
1744-
Times out after180 seconds.
1747+
Times out after$TestLib::timeout_default seconds.
17451748
Returns 1 if successful, 0 if timed out.
17461749
17471750
=cut
@@ -1754,7 +1757,7 @@ sub poll_query_until
17541757

17551758
my$cmd = ['psql','-XAt','-d',$self->connstr($dbname) ];
17561759
my ($stdout,$stderr);
1757-
my$max_attempts =180 *10;
1760+
my$max_attempts =10 *$TestLib::timeout_default;
17581761
my$attempts = 0;
17591762

17601763
while ($attempts <$max_attempts)
@@ -1776,8 +1779,8 @@ sub poll_query_until
17761779
$attempts++;
17771780
}
17781781

1779-
#The query result didn't change in 180 seconds. Give up. Print the
1780-
#output from the last attempt, hopefully that's usefulfor debugging.
1782+
#Give up. Print the output from the last attempt, hopefully that's useful
1783+
# for debugging.
17811784
diagqq(poll_query_until timed out executing this query:
17821785
$query
17831786
expecting this output:

‎src/test/perl/TestLib.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ our @EXPORT = qw(
5252
$windows_os
5353
);
5454

55-
our ($windows_os,$tmp_check,$log_path,$test_logfile);
55+
our ($windows_os,$timeout_default,$tmp_check,$log_path,$test_logfile);
5656

5757
BEGIN
5858
{
@@ -101,6 +101,10 @@ BEGIN
101101
require Win32API::File;
102102
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
103103
}
104+
105+
$timeout_default =$ENV{PG_TEST_TIMEOUT_DEFAULT};
106+
$timeout_default = 180
107+
ifnotdefined$timeout_defaultor$timeout_defaulteq'';
104108
}
105109

106110
INIT

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
);
7878

7979
my$stdout_recv =$node_master->pg_recvlogical_upto(
80-
'postgres','test_slot',$endpos,180,
80+
'postgres','test_slot',$endpos,$TestLib::timeout_default,
8181
'include-xids'=>'0',
8282
'skip-empty-xacts'=>'1');
8383
chomp($stdout_recv);
@@ -89,7 +89,7 @@
8989
)ordie"slot never became inactive";
9090

9191
$stdout_recv =$node_master->pg_recvlogical_upto(
92-
'postgres','test_slot',$endpos,180,
92+
'postgres','test_slot',$endpos,$TestLib::timeout_default,
9393
'include-xids'=>'0',
9494
'skip-empty-xacts'=>'1');
9595
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
@@ -122,7 +122,7 @@ sub init_start
122122
\$stdout,
123123
'2>',
124124
\$stderr,
125-
IPC::Run::timeout(900));# five times the poll_query_until timeout
125+
IPC::Run::timeout(5 *$TestLib::timeout_default));
126126
ok($gnat->poll_query_until(
127127
'postgres',
128128
"SELECT 1 FROM pg_stat_activity WHERE query = '$slow_query'",'1'),
@@ -133,10 +133,11 @@ sub init_start
133133
unlink($gnat->data_dir .'/postmaster.pid');
134134
$gnat->rotate_logfile;
135135
log_ipcs();
136-
# Reject ordinary startup. Retry for the same reasons poll_start() does.
136+
# Reject ordinary startup. Retry for the same reasons poll_start() does,
137+
# every 0.1s for at least $TestLib::timeout_default seconds.
137138
my$pre_existing_msg =qr/pre-existing shared memory block/;
138139
{
139-
my$max_attempts =180 *10;# Retry every 0.1s for at least 180s.
140+
my$max_attempts =10 *$TestLib::timeout_default;
140141
my$attempts = 0;
141142
while ($attempts <$max_attempts)
142143
{
@@ -186,7 +187,7 @@ sub poll_start
186187
{
187188
my ($node) =@_;
188189

189-
my$max_attempts =180 *10;
190+
my$max_attempts =10 *$TestLib::timeout_default;
190191
my$attempts = 0;
191192

192193
while ($attempts <$max_attempts)
@@ -202,8 +203,8 @@ sub poll_start
202203
$attempts++;
203204
}
204205

205-
#No success within 180 seconds.Try one last time without fail_ok, which
206-
#will BAIL_OUT unless itsucceeds.
206+
# Try one last time without fail_ok, which will BAIL_OUT unless it
207+
# succeeds.
207208
$node->start &&return 1;
208209
return 0;
209210
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp