diff options
| author | Thomas Munro | 2019-10-16 20:59:21 +0000 |
|---|---|---|
| committer | Thomas Munro | 2019-10-16 21:14:51 +0000 |
| commit | 080cf32d22317591cd8891c797a4d925cf1dbda2 (patch) | |
| tree | 9375173d9169c107ecdfd905a3f967b85e5f798c | |
| parent | bc3a94dc00059955aeb611d611d064faf66dc2f8 (diff) | |
Fix bug that could try to freeze running multixacts.
Commits 801c2dc7 and 801c2dc7 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
| -rw-r--r-- | src/backend/commands/vacuum.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 35f07f0369c..ed91d0e0e13 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -429,6 +429,7 @@ vacuum_set_xid_limits(Relation rel, int effective_multixact_freeze_max_age; TransactionId limit; TransactionId safeLimit; + MultiXactId oldestMxact; MultiXactId mxactLimit; MultiXactId safeMxactLimit; @@ -504,7 +505,8 @@ vacuum_set_xid_limits(Relation rel, Assert(mxid_freezemin >= 0); /* compute the cutoff multi, being careful to generate a valid value */ - mxactLimit = GetOldestMultiXactId() - mxid_freezemin; + oldestMxact = GetOldestMultiXactId(); + mxactLimit = oldestMxact - mxid_freezemin; if (mxactLimit < FirstMultiXactId) mxactLimit = FirstMultiXactId; @@ -518,7 +520,11 @@ vacuum_set_xid_limits(Relation rel, ereport(WARNING, (errmsg("oldest multixact is far in the past"), errhint("Close open transactions with multixacts soon to avoid wraparound problems."))); - mxactLimit = safeMxactLimit; + /* Use the safe limit, unless an older mxact is still running */ + if (MultiXactIdPrecedes(oldestMxact, safeMxactLimit)) + mxactLimit = oldestMxact; + else + mxactLimit = safeMxactLimit; } *multiXactCutoff = mxactLimit; |
