Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6761212

Browse files
committed
Merge branch 'PGPROEE10' into PGPROEE10_pg_shardman
2 parents bed14af + a4ef208 commit 6761212

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/backend/access/heap/heapam.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,6 +2909,19 @@ heap_page_prepare_for_xid(Relation relation, Buffer buffer,
29092909

29102910
delta = (int64) (xid - FirstNormalTransactionId) - (int64) base;
29112911

2912+
if (xid < base + delta + FirstNormalTransactionId ||
2913+
xid > base + delta + MaxShortTransactionId)
2914+
{
2915+
elog(FATAL, "Fatal xid base calculation error: "
2916+
"xid = " XID_FMT ", "
2917+
"base = " XID_FMT ", "
2918+
"min = %u, "
2919+
"max = %u, "
2920+
"delta = " INT64_FORMAT,
2921+
xid, base, min, max, delta
2922+
);
2923+
}
2924+
29122925
Assert(xid >= base + delta + FirstNormalTransactionId);
29132926
Assert(xid <= base + delta + MaxShortTransactionId);
29142927

@@ -2926,6 +2939,9 @@ heap_page_prepare_for_xid(Relation relation, Buffer buffer,
29262939
int64 freeDelta = MaxShortTransactionId - max,
29272940
requiredDelta = (base + FirstNormalTransactionId) - xid;
29282941

2942+
/* Shouldn't consider setting base less than 0 */
2943+
freeDelta = Min(freeDelta, base);
2944+
29292945
if (requiredDelta <= freeDelta)
29302946
{
29312947
int64 delta = - (freeDelta + requiredDelta) / 2;
@@ -2967,6 +2983,21 @@ heap_page_prepare_for_xid(Relation relation, Buffer buffer,
29672983
{
29682984
int64 delta = (freeDelta + requiredDelta) / 2;
29692985

2986+
if (xid < base + delta + FirstNormalTransactionId ||
2987+
xid > base + delta + MaxShortTransactionId)
2988+
{
2989+
elog(FATAL, "Fatal xid base calculation error: "
2990+
"xid = " XID_FMT ", "
2991+
"base = " XID_FMT ", "
2992+
"min = %u, "
2993+
"max = %u, "
2994+
"freeDelta = " INT64_FORMAT ", "
2995+
"requiredDelta = " INT64_FORMAT ", "
2996+
"delta = " INT64_FORMAT,
2997+
xid, base, min, max, freeDelta, requiredDelta, delta
2998+
);
2999+
}
3000+
29703001
Assert(xid >= base + delta + FirstNormalTransactionId);
29713002
Assert(xid <= base + delta + MaxShortTransactionId);
29723003

src/backend/storage/ipc/procarray.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,9 +1816,10 @@ PgGetSnapshotData(Snapshot snapshot)
18161816
globalxmin = xmin;
18171817

18181818
/* Update global variables too */
1819-
RecentGlobalXmin = globalxmin - vacuum_defer_cleanup_age;
1820-
if (!TransactionIdIsNormal(RecentGlobalXmin))
1819+
if (globalxmin <= FirstNormalTransactionId + vacuum_defer_cleanup_age)
18211820
RecentGlobalXmin = FirstNormalTransactionId;
1821+
else
1822+
RecentGlobalXmin = globalxmin - vacuum_defer_cleanup_age;
18221823

18231824
/* Check whether there's a replication slot requiring an older xmin. */
18241825
if (TransactionIdIsValid(replication_slot_xmin) &&

0 commit comments

Comments
 (0)