From c42c38138e73ae59d8d825bd7a549bc05cf232f8 Mon Sep 17 00:00:00 2001 From: Kosntantin Knizhnik Date: Sat, 12 Jul 2025 15:55:41 +0300 Subject: [PATCH] Set request_lsn=max(gc_cutoff,request_lsn) --- pgxn/neon/communicator.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pgxn/neon/communicator.c b/pgxn/neon/communicator.c index bd53855eab..ec2851f3c4 100644 --- a/pgxn/neon/communicator.c +++ b/pgxn/neon/communicator.c @@ -2227,6 +2227,19 @@ Retry: case T_NeonGetPageResponse: { NeonGetPageResponse* getpage_resp = (NeonGetPageResponse *) resp; + if (resp->lsn != UINT64_MAX) /* replica */ + { + XLogRecPtr page_lsn = PageGetLSN((Page)getpage_resp->page); + XLogRecPtr replay_lsn = GetXLogReplayRecPtr(NULL); + if (page_lsn > replay_lsn) + { + /* Alternative to throw error is to repeat the query with request_lsn=replay_lsn */ + ereport(ERROR, + (errcode(ERRCODE_IO_ERROR), + errmsg("There is no more version of page %u of relation %u/%u/%u.%u at LSN %X/%X at page server, latest version is at LSN %X/%X", + blockno, RelFileInfoFmt(rinfo), forkNum, LSN_FORMAT_ARGS(replay_lsn), LSN_FORMAT_ARGS(page_lsn)))); + } + } memcpy(buffer, getpage_resp->page, BLCKSZ); /*