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

Commitebf6de8

Browse files
committed
Add more TAP coverage for archive status with crash recovery of standbys
This part of the test was included originally in4e87c48, but gotreverted as off9c1b8d because of timing issues in the test, where,after more analysis, we found that the standbys may not have recoveredfrom the archives all the segments needed by the test. This stabilizesthe test by making sure that standbys replay up to the position returnedby pg_switch_wal(), meaning that all segments are recovered before themanual checkpoint that tests WAL segment recycling and its interactionswith archive status files.Author: Jehan-Guillaume de RorthaisReviewed-by: Kyotaro Horiguchi, Michael PaquierDiscussion:https://postgr.es/m/20200424034248.GL33034@paquier.xyz
1 parent0278d3f commitebf6de8

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

‎src/test/recovery/t/020_archive_status.pl

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use warnings;
66
use PostgresNode;
77
use TestLib;
8-
use Test::Moretests=>13;
8+
use Test::Moretests=>16;
99
use Config;
1010

1111
my$primary = get_new_node('master');
@@ -119,10 +119,16 @@
119119
$primary->safe_psql(
120120
'postgres',q{
121121
INSERT INTO mine SELECT generate_series(10,20) AS x;
122-
SELECT pg_switch_wal();
123122
CHECKPOINT;
124123
});
125124

125+
# Switch to a new segment and use the returned LSN to make sure that
126+
# standbys have caught up to this point.
127+
my$primary_lsn =$primary->safe_psql(
128+
'postgres',q{
129+
SELECT pg_switch_wal();
130+
});
131+
126132
$primary->poll_query_until('postgres',
127133
q{ SELECT last_archived_wal FROM pg_stat_archiver},
128134
$segment_name_2)
@@ -134,14 +140,32 @@
134140
$standby1->append_conf('postgresql.conf',"archive_mode = on");
135141
my$standby1_data =$standby1->data_dir;
136142
$standby1->start;
143+
144+
# Wait for the replay of the segment switch done previously, ensuring
145+
# that all segments needed are restored from the archives.
146+
$standby1->poll_query_until('postgres',
147+
qq{ SELECT pg_wal_lsn_diff(pg_last_wal_replay_lsn(), '$primary_lsn') >= 0}
148+
)ordie"Timed out while waiting for xlog replay on standby2";
149+
137150
$standby1->safe_psql('postgres',q{CHECKPOINT});
138151

152+
# Recovery with archive_mode=on does not keep .ready signal files inherited
153+
# from backup. Note that this WAL segment existed in the backup.
154+
ok( !-f"$standby1_data/$segment_path_1_ready",
155+
".ready file for WAL segment$segment_name_1 present in backup got removed with archive_mode=on on standby"
156+
);
157+
139158
# Recovery with archive_mode=on should not create .ready files.
140159
# Note that this segment did not exist in the backup.
141160
ok( !-f"$standby1_data/$segment_path_2_ready",
142161
".ready file for WAL segment$segment_name_2 not created on standby when archive_mode=on on standby"
143162
);
144163

164+
# Recovery with archive_mode = on creates .done files.
165+
ok(-f"$standby1_data/$segment_path_2_done",
166+
".done file for WAL segment$segment_name_2 created when archive_mode=on on standby"
167+
);
168+
145169
# Test recovery with archive_mode = always, which should always keep
146170
# .ready files if archiving is enabled, though here we want the archive
147171
# command to fail to persist the .ready files. Note that this node
@@ -153,12 +177,22 @@
153177
my$standby2_data =$standby2->data_dir;
154178
$standby2->start;
155179

180+
# Wait for the replay of the segment switch done previously, ensuring
181+
# that all segments needed are restored from the archives.
182+
$standby2->poll_query_until('postgres',
183+
qq{ SELECT pg_wal_lsn_diff(pg_last_wal_replay_lsn(), '$primary_lsn') >= 0}
184+
)ordie"Timed out while waiting for xlog replay on standby2";
185+
156186
$standby2->safe_psql('postgres',q{CHECKPOINT});
157187

158188
ok(-f"$standby2_data/$segment_path_1_ready",
159189
".ready file for WAL segment$segment_name_1 existing in backup is kept with archive_mode=always on standby"
160190
);
161191

192+
ok(-f"$standby2_data/$segment_path_2_ready",
193+
".ready file for WAL segment$segment_name_2 created with archive_mode=always on standby"
194+
);
195+
162196
# Reset statistics of the archiver for the next checks.
163197
$standby2->safe_psql('postgres',q{SELECT pg_stat_reset_shared('archiver')});
164198

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp