Skip to content

Commit 0d028b7

Browse files
committed
wal_bytes for ARCHIVE backups was calculated incorrectly
1 parent 2d2da50 commit 0d028b7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/backup.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,19 @@ do_backup(time_t start_time, bool no_validate,
798798
/* compute size of wal files of this backup stored in the archive */
799799
if (!current.stream)
800800
{
801-
current.wal_bytes = instance_config.xlog_seg_size *
802-
(current.stop_lsn / instance_config.xlog_seg_size -
803-
current.start_lsn / instance_config.xlog_seg_size + 1);
801+
XLogSegNo start_segno;
802+
XLogSegNo stop_segno;
803+
804+
GetXLogSegNo(current.start_lsn, start_segno, instance_config.xlog_seg_size);
805+
GetXLogSegNo(current.stop_lsn, stop_segno, instance_config.xlog_seg_size);
806+
current.wal_bytes = (stop_segno - start_segno) * instance_config.xlog_seg_size;
807+
808+
/*
809+
* If start_lsn and stop_lsn are located in the same segment, then
810+
* set wal_bytes to the size of 1 segment.
811+
*/
812+
if (current.wal_bytes <= 0)
813+
current.wal_bytes = instance_config.xlog_seg_size;
804814
}
805815

806816
/* Backup is done. Update backup status */

0 commit comments

Comments
 (0)