From 1b07baeecfc5407c263c0303560dcb7849fa6e89 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Fri, 25 Aug 2023 04:12:41 +0000 Subject: [PATCH 1/1] Fix false report of wraparound in pg_serial This corrects a condition when SLRU truncation falsely reports a pg_serial wraparound due to an in-flight serializable xid being ahead of the latest committed serializable xid in pg_serial. Discussion: https://www.postgresql.org/message-id/flat/5991E478-2DE4-4CE0-98D6-62F090F3505B%40amazon.com --- src/backend/storage/lmgr/predicate.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 1af41213b4..7e7be3b885 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -992,6 +992,13 @@ SerialSetActiveSerXmin(TransactionId xid) serialControl->tailXid = xid; + /* + * If the SLRU is being used, set the latest page number to + * the current tail xid. + */ + if (serialControl->headPage > 0) + SerialSlruCtl->shared->latest_page_number = SerialPage(serialControl->tailXid); + LWLockRelease(SerialSLRULock); } -- 2.40.1