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

Commit2a724cd

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 parentad1f288 commit2a724cd

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
@@ -5461,7 +5461,6 @@ validateRecoveryParameters(void)
54615461
staticvoid
54625462
exitArchiveRecovery(TimeLineIDendTLI,XLogRecPtrendOfLog)
54635463
{
5464-
charrecoveryPath[MAXPGPATH];
54655464
charxlogfname[MAXFNAMELEN];
54665465
XLogSegNoendLogSegNo;
54675466
XLogSegNostartLogSegNo;
@@ -5541,17 +5540,6 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
55415540
XLogFileName(xlogfname,ThisTimeLineID,startLogSegNo,wal_segment_size);
55425541
XLogArchiveCleanup(xlogfname);
55435542

5544-
/*
5545-
* Since there might be a partial WAL segment named RECOVERYXLOG, get rid
5546-
* of it.
5547-
*/
5548-
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYXLOG");
5549-
unlink(recoveryPath);/* ignore any error */
5550-
5551-
/* Get rid of any remaining recovered timeline-history file, too */
5552-
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYHISTORY");
5553-
unlink(recoveryPath);/* ignore any error */
5554-
55555543
/*
55565544
* Remove the signal files out of the way, so that we don't accidentally
55575545
* re-enter archive recovery mode in a subsequent crash.
@@ -7429,6 +7417,7 @@ StartupXLOG(void)
74297417
if (ArchiveRecoveryRequested)
74307418
{
74317419
charreason[200];
7420+
charrecoveryPath[MAXPGPATH];
74327421

74337422
Assert(InArchiveRecovery);
74347423

@@ -7485,6 +7474,17 @@ StartupXLOG(void)
74857474
*/
74867475
writeTimeLineHistory(ThisTimeLineID,recoveryTargetTLI,
74877476
EndRecPtr,reason);
7477+
7478+
/*
7479+
* Since there might be a partial WAL segment named RECOVERYXLOG, get
7480+
* rid of it.
7481+
*/
7482+
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYXLOG");
7483+
unlink(recoveryPath);/* ignore any error */
7484+
7485+
/* Get rid of any remaining recovered timeline-history file, too */
7486+
snprintf(recoveryPath,MAXPGPATH,XLOGDIR"/RECOVERYHISTORY");
7487+
unlink(recoveryPath);/* ignore any error */
74887488
}
74897489

74907490
/* 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