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

Commit8650d16

Browse files
committed
Make WAL-related utilities handle .partial WAL files properly.
Commitde76884 changed an archive recovery so that the last WALsegment with old timeline was renamed with suffix .partial. It shouldhave updated WAL-related utilities so that they can handle such.paritial WAL files, but we forgot that.This patch changes pg_archivecleanup so that it can clean up evenarchived WAL files with .partial suffix. Also it allows us to specify.partial WAL file name as the command-line argument "oldestkeptwalfile".This patch also changes pg_resetxlog so that it can remove .partialWAL files in pg_xlog directory.pg_xlogdump cannot handle .partial WAL files. Per discussion,we decided only to document that limitation instead of adding the fix.Because a user can easily work around the limitation (i.e., just remove.partial suffix from the file name) and the fix seems complicated forvery narrow use case.Back-patch to 9.5 where the problem existed.Review by Michael Paquier.Discussion:http://www.postgresql.org/message-id/CAHGQGwGxMKnVHGgTfiig2Bt_2djec0in3-DLJmtg7+nEiidFdQ@mail.gmail.com
1 parent5671aac commit8650d16

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

‎doc/src/sgml/ref/pg_xlogdump.sgml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ PostgreSQL documentation
215215
Only the specified timeline is displayed (or the default, if none is
216216
specified). Records in other timelines are ignored.
217217
</para>
218+
219+
<para>
220+
<application>pg_xlogdump</> cannot read WAL files with suffix
221+
<literal>.partial</>. If those files need to be read, <literal>.partial</>
222+
suffix needs to be removed from the filename.
223+
</para>
218224
</refsect1>
219225

220226
<refsect1>

‎doc/src/sgml/ref/pgarchivecleanup.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ archive_cleanup_command = 'pg_archivecleanup <replaceable>archivelocation</> %r'
6060
<para>
6161
When used as a standalone program all WAL files logically preceding the
6262
<replaceable>oldestkeptwalfile</> will be removed from <replaceable>archivelocation</>.
63-
In this mode, if you specify a <filename>.backup</> file name, then only the file prefix
64-
will be used as the <replaceable>oldestkeptwalfile</>. This allows you to remove
63+
In this mode, if you specify a <filename>.partial</> or <filename>.backup</>
64+
file name, then only the file prefix will be used as the
65+
<replaceable>oldestkeptwalfile</>. This treatment of <filename>.backup</>
66+
file name allows you to remove
6567
all WAL files archived prior to a specific base backup without error.
6668
For example, the following example will remove all files older than
6769
WAL file name <filename>000000010000003700000010</>:

‎src/bin/pg_archivecleanup/pg_archivecleanup.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ CleanupPriorWALFiles(void)
125125
* file. Note that this means files are not removed in the order
126126
* they were originally written, in case this worries you.
127127
*/
128-
if (IsXLogFileName(walfile)&&
128+
if ((IsXLogFileName(walfile)||IsPartialXLogFileName(walfile))&&
129129
strcmp(walfile+8,exclusiveCleanupFileName+8)<0)
130130
{
131131
/*
@@ -181,7 +181,7 @@ CleanupPriorWALFiles(void)
181181
* SetWALFileNameForCleanup()
182182
*
183183
* Set the earliest WAL filename that we want to keep on the archive
184-
* and decide whether weneed_cleanup
184+
* and decide whether weneed cleanup
185185
*/
186186
staticvoid
187187
SetWALFileNameForCleanup(void)
@@ -192,16 +192,37 @@ SetWALFileNameForCleanup(void)
192192

193193
/*
194194
* If restartWALFileName is a WAL file name then just use it directly. If
195-
* restartWALFileName is a .backup filename, make sure we use the prefix
196-
* of the filename, otherwise we will remove wrong files since
197-
* 000000010000000000000010.00000020.backup is after
195+
* restartWALFileName is a .partial or .backup filename, make sure we use
196+
* the prefix of the filename, otherwise we will remove wrong files since
197+
* 000000010000000000000010.partial and
198+
* 000000010000000000000010.00000020.backup are after
198199
* 000000010000000000000010.
199200
*/
200201
if (IsXLogFileName(restartWALFileName))
201202
{
202203
strcpy(exclusiveCleanupFileName,restartWALFileName);
203204
fnameOK= true;
204205
}
206+
elseif (IsPartialXLogFileName(restartWALFileName))
207+
{
208+
intargs;
209+
uint32tli=1,
210+
log=0,
211+
seg=0;
212+
213+
args=sscanf(restartWALFileName,"%08X%08X%08X.partial",
214+
&tli,&log,&seg);
215+
if (args==3)
216+
{
217+
fnameOK= true;
218+
219+
/*
220+
* Use just the prefix of the filename, ignore everything after
221+
* first period
222+
*/
223+
XLogFileNameById(exclusiveCleanupFileName,tli,log,seg);
224+
}
225+
}
205226
elseif (IsBackupHistoryFileName(restartWALFileName))
206227
{
207228
intargs;

‎src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,8 @@ FindEndOfXLOG(void)
906906

907907
while (errno=0, (xlde=readdir(xldir))!=NULL)
908908
{
909-
if (IsXLogFileName(xlde->d_name))
909+
if (IsXLogFileName(xlde->d_name)||
910+
IsPartialXLogFileName(xlde->d_name))
910911
{
911912
unsignedinttli,
912913
log,
@@ -976,7 +977,8 @@ KillExistingXLOG(void)
976977

977978
while (errno=0, (xlde=readdir(xldir))!=NULL)
978979
{
979-
if (IsXLogFileName(xlde->d_name))
980+
if (IsXLogFileName(xlde->d_name)||
981+
IsPartialXLogFileName(xlde->d_name))
980982
{
981983
snprintf(path,MAXPGPATH,"%s/%s",XLOGDIR,xlde->d_name);
982984
if (unlink(path)<0)
@@ -1028,7 +1030,9 @@ KillExistingArchiveStatus(void)
10281030
{
10291031
if (strspn(xlde->d_name,"0123456789ABCDEF")==XLOG_FNAME_LEN&&
10301032
(strcmp(xlde->d_name+XLOG_FNAME_LEN,".ready")==0||
1031-
strcmp(xlde->d_name+XLOG_FNAME_LEN,".done")==0))
1033+
strcmp(xlde->d_name+XLOG_FNAME_LEN,".done")==0||
1034+
strcmp(xlde->d_name+XLOG_FNAME_LEN,".partial.ready")==0||
1035+
strcmp(xlde->d_name+XLOG_FNAME_LEN,".partial.done")==0))
10321036
{
10331037
snprintf(path,MAXPGPATH,"%s/%s",ARCHSTATDIR,xlde->d_name);
10341038
if (unlink(path)<0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp