Skip to content

Commit 9453cf0

Browse files
committed
bugfix: correctly append streamed segments to backup filelist
1 parent 6defc76 commit 9453cf0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/pg_probackup.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@ typedef struct BackupPageHeader2
649649
strcmp((fname) + XLOG_FNAME_LEN, ".gz") == 0)
650650

651651
#if PG_VERSION_NUM >= 110000
652+
653+
#define WalSegmentOffset(xlogptr, wal_segsz_bytes) \
654+
XLogSegmentOffset(xlogptr, wal_segsz_bytes)
652655
#define GetXLogSegNo(xlrp, logSegNo, wal_segsz_bytes) \
653656
XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
654657
#define GetXLogRecPtr(segno, offset, wal_segsz_bytes, dest) \
@@ -668,6 +671,8 @@ typedef struct BackupPageHeader2
668671
#define GetXLogFromFileName(fname, tli, logSegNo, wal_segsz_bytes) \
669672
XLogFromFileName(fname, tli, logSegNo, wal_segsz_bytes)
670673
#else
674+
#define WalSegmentOffset(xlogptr, wal_segsz_bytes) \
675+
XLogSegmentOffset(xlogptr)
671676
#define GetXLogSegNo(xlrp, logSegNo, wal_segsz_bytes) \
672677
XLByteToSeg(xlrp, logSegNo)
673678
#define GetXLogRecPtr(segno, offset, wal_segsz_bytes, dest) \

src/stream.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,13 @@ stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished)
290290

291291
GetXLogSegNo(xlogpos, xlog_segno, instance_config.xlog_seg_size);
292292

293-
/* xlogpos points to the current segment, and we need the finished - previous one */
294-
xlog_segno--;
293+
/*
294+
* xlogpos points to the current segment, and we need the finished - previous one
295+
* inless xlogpos points to not 0 offset in segment
296+
*/
297+
if (WalSegmentOffset(xlogpos, instance_config.xlog_seg_size) == 0)
298+
xlog_segno--;
299+
295300
GetXLogFileName(wal_segment_name, timeline, xlog_segno,
296301
instance_config.xlog_seg_size);
297302

0 commit comments

Comments
 (0)