Skip to content

Commit 55a5ee3

Browse files
committed
Fix incorrect calculation in BlockRefTableEntryGetBlocks.
The previous formula was incorrect in the case where the function's nblocks argument was a multiple of BLOCKS_PER_CHUNK, which happens whenever a relation segment file is exactly 512MB or exactly 1GB in length. In such cases, the formula would calculate a stop_offset of 0 rather than 65536, resulting in modified blocks in the second half of a 1GB file, or all the modified blocks in a 512MB file, being omitted from the incremental backup. Reported off-list by Tomas Vondra and Jakub Wartak. Discussion: http://postgr.es/m/CA+TgmoYwy_KHp1-5GYNmVa=zdeJWhNH1T0SBmEuvqQNJEHj1Lw@mail.gmail.com
1 parent 079d94a commit 55a5ee3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/common/blkreftable.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ BlockRefTableEntryGetBlocks(BlockRefTableEntry *entry,
410410
if (chunkno == start_chunkno)
411411
start_offset = start_blkno % BLOCKS_PER_CHUNK;
412412
if (chunkno == stop_chunkno - 1)
413-
stop_offset = stop_blkno % BLOCKS_PER_CHUNK;
413+
{
414+
Assert(stop_blkno > chunkno * BLOCKS_PER_CHUNK);
415+
stop_offset = stop_blkno - (chunkno * BLOCKS_PER_CHUNK);
416+
Assert(stop_offset <= BLOCKS_PER_CHUNK);
417+
}
414418

415419
/*
416420
* Handling differs depending on whether this is an array of offsets

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy