Skip to content

Commit 6bda2af

Browse files
committed
Fix bug that could try to freeze running multixacts.
Commits 801c2dc and 801c2dc made it possible for vacuum to try to freeze a multixact that is still running. That was prevented by a check, but raised an error. Repair. Back-patch all the way. Author: Nathan Bossart, Jeremy Schneider Reported-by: Jeremy Schneider Reviewed-by: Jim Nasby, Thomas Munro Discussion: https://postgr.es/m/DAFB8AFF-2F05-4E33-AD7F-FF8B0F760C17%40amazon.com
1 parent 0d21f91 commit 6bda2af

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/commands/vacuum.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ vacuum_set_xid_limits(Relation rel,
893893
int effective_multixact_freeze_max_age;
894894
TransactionId limit;
895895
TransactionId safeLimit;
896+
MultiXactId oldestMxact;
896897
MultiXactId mxactLimit;
897898
MultiXactId safeMxactLimit;
898899

@@ -970,7 +971,8 @@ vacuum_set_xid_limits(Relation rel,
970971
Assert(mxid_freezemin >= 0);
971972

972973
/* compute the cutoff multi, being careful to generate a valid value */
973-
mxactLimit = GetOldestMultiXactId() - mxid_freezemin;
974+
oldestMxact = GetOldestMultiXactId();
975+
mxactLimit = oldestMxact - mxid_freezemin;
974976
if (mxactLimit < FirstMultiXactId)
975977
mxactLimit = FirstMultiXactId;
976978

@@ -984,7 +986,11 @@ vacuum_set_xid_limits(Relation rel,
984986
ereport(WARNING,
985987
(errmsg("oldest multixact is far in the past"),
986988
errhint("Close open transactions with multixacts soon to avoid wraparound problems.")));
987-
mxactLimit = safeMxactLimit;
989+
/* Use the safe limit, unless an older mxact is still running */
990+
if (MultiXactIdPrecedes(oldestMxact, safeMxactLimit))
991+
mxactLimit = oldestMxact;
992+
else
993+
mxactLimit = safeMxactLimit;
988994
}
989995

990996
*multiXactCutoff = mxactLimit;

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