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

Commit a25c2b7

Browse files
committed
Accept pg_upgraded tuples during multixact freezing
The new MultiXact freezing routines introduced by commit 8e9a16a neglected to consider tuples that came from a pg_upgrade'd database; a vacuum run that tried to freeze such tuples would die with an error such as ERROR: MultiXactId 11415437 does no longer exist -- apparent wraparound To fix, ensure that GetMultiXactIdMembers is allowed to return empty multis when the infomask bits are right, as is done in other callsites. Per trouble report from F-Secure. In passing, fix a copy&paste bug reported by Andrey Karpov from VIVA64 from their PVS-Studio static checked, that instead of setting relminmxid to Invalid, we were setting relfrozenxid twice. Not an important mistake because that code branch is about relations for which we don't use the frozenxid/minmxid values at all in the first place, but seems to warrants a fix nonetheless.
1 parent 28fff0e commit a25c2b7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/backend/access/heap/heapam.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5288,6 +5288,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
52885288
bool has_lockers;
52895289
TransactionId update_xid;
52905290
bool update_committed;
5291+
bool allow_old;
52915292

52925293
*flags = 0;
52935294

@@ -5349,7 +5350,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
53495350
* anything.
53505351
*/
53515352

5352-
nmembers = GetMultiXactIdMembers(multi, &members, false);
5353+
allow_old = !(t_infomask & HEAP_LOCK_MASK) &&
5354+
HEAP_XMAX_IS_LOCKED_ONLY(t_infomask);
5355+
nmembers = GetMultiXactIdMembers(multi, &members, allow_old);
53535356
if (nmembers <= 0)
53545357
{
53555358
/* Nothing worth keeping */
@@ -6060,10 +6063,13 @@ heap_tuple_needs_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
60606063
MultiXactMember *members;
60616064
int nmembers;
60626065
int i;
6066+
bool allow_old;
60636067

60646068
/* need to check whether any member of the mxact is too old */
60656069

6066-
nmembers = GetMultiXactIdMembers(multi, &members, false);
6070+
allow_old = !(tuple->t_infomask & HEAP_LOCK_MASK) &&
6071+
HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask);
6072+
nmembers = GetMultiXactIdMembers(multi, &members, allow_old);
60676073

60686074
for (i = 0; i < nmembers; i++)
60696075
{

src/backend/catalog/heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ AddNewRelationTuple(Relation pg_class_desc,
903903
* commands/sequence.c.)
904904
*/
905905
new_rel_reltup->relfrozenxid = InvalidTransactionId;
906-
new_rel_reltup->relfrozenxid = InvalidMultiXactId;
906+
new_rel_reltup->relminmxid = InvalidMultiXactId;
907907
}
908908

909909
new_rel_reltup->relowner = relowner;

0 commit comments

Comments
 (0)