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

Commit6c1c9f8

Browse files
committed
Improve recently-added test reliability
Commit59be1c9 already tried to makesrc/test/recovery/t/033_replay_tsp_drops more reliable, but it wasn'tenough. Try to improve on that by making this use of a replication slotto be more like others. Also, don't drop the slot.Make a few other stylistic changes while at it. It's still quite slow,which is another thing that we need to fix in this script.Backpatch to all supported branches.Discussion:https://postgr.es/m/349302.1659191875@sss.pgh.pa.us
1 parent70d25bf commit6c1c9f8

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

‎src/test/recovery/t/033_replay_tsp_drops.pl

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PostgreSQL::Test::Cluster;
1010
use PostgreSQL::Test::Utils;
1111
use Test::More;
12+
use Time::HiResqw(usleep);
1213

1314
subtest_tablespace
1415
{
@@ -36,14 +37,13 @@ sub test_tablespace
3637
has_streaming=> 1);
3738
$node_standby->append_conf('postgresql.conf',
3839
"allow_in_place_tablespaces = on");
40+
$node_standby->append_conf('postgresql.conf',
41+
"primary_slot_name = slot");
3942
$node_standby->start;
4043

41-
# Make sure connection is made
42-
$node_primary->poll_query_until('postgres',
43-
'SELECT count(*) = 1 FROM pg_stat_replication');
44-
$node_primary->safe_psql('postgres',"SELECT pg_drop_replication_slot('slot')");
45-
46-
$node_standby->safe_psql('postgres','CHECKPOINT');
44+
# Make sure the connection is made
45+
$node_primary->wait_for_catchup($node_standby,'write',
46+
$node_primary->lsn('write'));
4747

4848
# Do immediate shutdown just after a sequence of CREATE DATABASE / DROP
4949
# DATABASE / DROP TABLESPACE. This causes CREATE DATABASE WAL records
@@ -62,10 +62,10 @@ sub test_tablespace
6262
DROP TABLESPACE source_ts;
6363
DROP DATABASE template_db;
6464
];
65-
6665
$query =~s/<STRATEGY>/$strategy/g;
66+
6767
$node_primary->safe_psql('postgres',$query);
68-
$node_primary->wait_for_catchup($node_standby,'replay',
68+
$node_primary->wait_for_catchup($node_standby,'write',
6969
$node_primary->lsn('write'));
7070

7171
# show "create missing directory" log message
@@ -119,7 +119,7 @@ sub test_tablespace
119119
my$tspdir =$node_standby->data_dir ."/pg_tblspc/$tspoid";
120120
File::Path::rmtree($tspdir);
121121

122-
my$logstart =get_log_size($node_standby);
122+
my$logstart =-s$node_standby->logfile;
123123

124124
# Create a database in the tablespace and a table in default tablespace
125125
$node_primary->safe_psql(
@@ -133,39 +133,26 @@ sub test_tablespace
133133
# Standby should fail and should not silently skip replaying the wal
134134
# In this test, PANIC turns into WARNING by allow_in_place_tablespaces.
135135
# Check the log messages instead of confirming standby failure.
136-
my$max_attempts =$PostgreSQL::Test::Utils::timeout_default;
136+
my$max_attempts =$PostgreSQL::Test::Utils::timeout_default * 10;
137137
while ($max_attempts-- >= 0)
138138
{
139139
last
140140
if (
141141
find_in_log(
142142
$node_standby,qr!WARNING: ( [A-Z0-9]+:)? creating missing directory: pg_tblspc/!,
143143
$logstart));
144-
sleep 1;
144+
usleep(100_000);
145145
}
146146
ok($max_attempts > 0,"invalid directory creation is detected");
147147

148148
done_testing();
149149

150-
151-
# return the size of logfile of $node in bytes
152-
subget_log_size
153-
{
154-
my ($node) =@_;
155-
156-
return (stat$node->logfile)[7];
157-
}
158-
159150
# find $pat in logfile of $node after $off-th byte
160151
subfind_in_log
161152
{
162153
my ($node,$pat,$off) =@_;
163154

164-
$off = 0unlessdefined$off;
165-
my$log = PostgreSQL::Test::Utils::slurp_file($node->logfile);
166-
return 0if (length($log) <=$off);
167-
168-
$log =substr($log,$off);
155+
my$log = PostgreSQL::Test::Utils::slurp_file($node->logfile,$off);
169156

170157
return$log =~m/$pat/;
171158
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp