Skip to content

Commit 3048dae

Browse files
author
Konstantin Knizhnik
committed
Use ctl->PagePrecedes for SLRU page comparison in SimpleLruDownloadSegment to address wraparround
1 parent 0160337 commit 3048dae

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/backend/access/transam/slru.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
618618
}
619619

620620

621+
/*
622+
* NEON: we do not want to include large pg_xact/multixact files in basebackup and prefer
623+
* to download them on demand to reduce startup time.
624+
* If SLRU segment is not found, we try to download it from page server
625+
*/
621626
static int
622627
SimpleLruDownloadSegment(SlruCtl ctl, int pageno, char const* path)
623628
{
@@ -628,8 +633,8 @@ SimpleLruDownloadSegment(SlruCtl ctl, int pageno, char const* path)
628633

629634
static SMgrRelationData dummy_smgr_rel = {0};
630635

631-
/* If page is beyond latest written page, then do not try to download segment from server */
632-
if (pageno > ctl->shared->latest_page_number)
636+
/* If page is greater than latest written page, then do not try to download segment from server */
637+
if (ctl->PagePrecedes(ctl->shared->latest_page_number, pageno))
633638
return -1;
634639

635640
if (!dummy_smgr_rel.smgr)

src/backend/storage/smgr/smgr.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,15 @@ smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
538538
buffer, skipFsync);
539539
}
540540

541+
/*
542+
* NEON: we do not want to include large pg_xact/multixact files in basebackup and prefer
543+
* to download them on demand to reduce startup time.
544+
* If SLRU segment is not found, we try to download it from page server
545+
*
546+
* This function returns number of blocks in segment. Usually it should be SLRU_PAGES_PER_SEGMENT but in case
547+
* of partial segment, it can be smaller. Zero value means that segment doesn't exist.
548+
* From Postgres point of view empty segment is the same as absent segment.
549+
*/
541550
int
542551
smgr_read_slru_segment(SMgrRelation reln, const char* path, int segno, void* buffer)
543552
{

0 commit comments

Comments
 (0)