1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-20 11:34:51 +02:00

PGPRO-1303: delete_walfiles() removes compressed WAL files too

This commit is contained in:
Arthur Zakirov 2018-01-16 14:40:02 +03:00
parent 7ee0803849
commit 2a87b31c4f
2 changed files with 10 additions and 2 deletions

View File

@ -321,7 +321,7 @@ delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli)
while (errno = 0, (arcde = readdir(arcdir)) != NULL)
{
/*
* We ignore the timeline part of the XLOG segment identifiers in
* We ignore the timeline part of the WAL segment identifiers in
* deciding whether a segment is still needed. This ensures that
* we won't prematurely remove a segment from a parent timeline.
* We could probably be a little more proactive about removing
@ -332,10 +332,13 @@ delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli)
* decide which ones are earlier than the exclusiveCleanupFileName
* file. Note that this means files are not removed in the order
* they were originally written, in case this worries you.
*
* We also should not forget that WAL segment can be compressed.
*/
if (IsXLogFileName(arcde->d_name) ||
IsPartialXLogFileName(arcde->d_name) ||
IsBackupHistoryFileName(arcde->d_name))
IsBackupHistoryFileName(arcde->d_name) ||
IsCompressedXLogFileName(arcde->d_name))
{
if (XLogRecPtrIsInvalid(oldest_lsn) ||
strncmp(arcde->d_name + 8, oldestSegmentNeeded + 8, 16) < 0)

View File

@ -257,6 +257,11 @@ typedef union DataPage
#define XLogDataFromLSN(data, xlogid, xrecoff) \
sscanf(data, "%X/%X", xlogid, xrecoff)
#define IsCompressedXLogFileName(fname) \
(strlen(fname) == XLOG_FNAME_LEN + strlen(".gz") && \
strspn(fname, "0123456789ABCDEF") == XLOG_FNAME_LEN && \
strcmp((fname) + XLOG_FNAME_LEN, ".gz") == 0)
/* directory options */
extern char *backup_path;
extern char backup_instance_path[MAXPGPATH];