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

Commitb978de0

Browse files
committed
Remove temporary WAL and history files at the end of archive recovery
cbc55da has reworked the order of some actions at the end of archiverecovery. Unfortunately this overlooked the fact that the startupprocess needs to remove RECOVERYXLOG (for temporary WAL segment newlyrecovered from archives) and RECOVERYHISTORY (for temporary historyfile) at this step, leaving the files around even after recovery ended.Backpatch to 9.5, like the previous commit.Author: Sawada MasahikoReviewed-by: Fujii Masao, Michael PaquierDiscussion:https://postgr.es/m/CAD21AoBO_eDQub6zojFnWtnmutRBWvYf7=cW4Hsqj+U_R26w3Q@mail.gmail.comBackpatch-through: 9.5
1 parentb81a82e commitb978de0

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5601,7 +5601,6 @@ readRecoveryCommandFile(void)
56015601
staticvoid
56025602
exitArchiveRecovery(TimeLineIDendTLI,XLogRecPtrendOfLog)
56035603
{
5604-
charrecoveryPath[MAXPGPATH];
56055604
charxlogfname[MAXFNAMELEN];
56065605
XLogSegNoendLogSegNo;
56075606
XLogSegNostartLogSegNo;
@@ -5681,17 +5680,6 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
56815680
XLogFileName(xlogfname,ThisTimeLineID,startLogSegNo,wal_segment_size);
56825681
XLogArchiveCleanup(xlogfname);
56835682

5684-
/*
5685-
* Since there might be a partial WAL segment named RECOVERYXLOG, get rid
5686-
* of it.
5687-
*/
5688-
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYXLOG");
5689-
unlink(recoveryPath);/* ignore any error */
5690-
5691-
/* Get rid of any remaining recovered timeline-history file, too */
5692-
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYHISTORY");
5693-
unlink(recoveryPath);/* ignore any error */
5694-
56955683
/*
56965684
* Rename the config file out of the way, so that we don't accidentally
56975685
* re-enter archive recovery mode in a subsequent crash.
@@ -7544,6 +7532,7 @@ StartupXLOG(void)
75447532
if (ArchiveRecoveryRequested)
75457533
{
75467534
charreason[200];
7535+
charrecoveryPath[MAXPGPATH];
75477536

75487537
Assert(InArchiveRecovery);
75497538

@@ -7600,6 +7589,17 @@ StartupXLOG(void)
76007589
*/
76017590
writeTimeLineHistory(ThisTimeLineID,recoveryTargetTLI,
76027591
EndRecPtr,reason);
7592+
7593+
/*
7594+
* Since there might be a partial WAL segment named RECOVERYXLOG, get
7595+
* rid of it.
7596+
*/
7597+
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYXLOG");
7598+
unlink(recoveryPath);/* ignore any error */
7599+
7600+
/* Get rid of any remaining recovered timeline-history file, too */
7601+
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYHISTORY");
7602+
unlink(recoveryPath);/* ignore any error */
76037603
}
76047604

76057605
/* Save the selected TimeLineID in shared memory, too */

‎src/test/recovery/t/002_archiving.pl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use warnings;
44
use PostgresNode;
55
use TestLib;
6-
use Test::Moretests=>1;
6+
use Test::Moretests=>3;
77
use File::Copy;
88

99
# Initialize master node, doing archives
@@ -49,3 +49,26 @@
4949
my$result =
5050
$node_standby->safe_psql('postgres',"SELECT count(*) FROM tab_int");
5151
is($result,qq(1000),'check content from archives');
52+
53+
# Check the presence of temporary files specifically generated during
54+
# archive recovery. To ensure the presence of the temporary history
55+
# file, switch to a timeline large enough to allow a standby to recover
56+
# a history file from an archive. As this requires at least two timeline
57+
# switches, promote the existing standby first. Then create a second
58+
# standby based on the promoted one. Finally, the second standby is
59+
# promoted.
60+
$node_standby->promote;
61+
62+
my$node_standby2 = get_new_node('standby2');
63+
$node_standby2->init_from_backup($node_master,$backup_name,
64+
has_restoring=> 1);
65+
$node_standby2->start;
66+
67+
# Now promote standby2, and check that temporary files specifically
68+
# generated during archive recovery are removed by the end of recovery.
69+
$node_standby2->promote;
70+
my$node_standby2_data =$node_standby2->data_dir;
71+
ok( !-f"$node_standby2_data/pg_wal/RECOVERYHISTORY",
72+
"RECOVERYHISTORY removed after promotion");
73+
ok( !-f"$node_standby2_data/pg_wal/RECOVERYXLOG",
74+
"RECOVERYXLOG removed after promotion");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp