mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Don't ignore tuple locks propagated by our updates
If a tuple was locked by transaction A, and transaction B updated it,
the new version of the tuple created by B would be locked by A, yet
visible only to B; due to an oversight in HeapTupleSatisfiesUpdate, the
lock held by A wouldn't get checked if transaction B later deleted (or
key-updated) the new version of the tuple. This might cause referential
integrity checks to give false positives (that is, allow deletes that
should have been rejected).
This is an easy oversight to have made, because prior to improved tuple
locks in commit 0ac5ad5134
it wasn't possible to have tuples created by
our own transaction that were also locked by remote transactions, and so
locks weren't even considered in that code path.
It is recommended that foreign keys be rechecked manually in bulk after
installing this update, in case some referenced rows are missing with
some referencing row remaining.
Per bug reported by Daniel Wood in
CAPweHKe5QQ1747X2c0tA=5zf4YnS2xcvGf13Opd-1Mq24rF1cQ@mail.gmail.com
This commit is contained in:
@ -1274,6 +1274,39 @@ retry:
|
||||
return truelength;
|
||||
}
|
||||
|
||||
/*
|
||||
* MultiXactHasRunningRemoteMembers
|
||||
* Does the given multixact have still-live members from
|
||||
* transactions other than our own?
|
||||
*/
|
||||
bool
|
||||
MultiXactHasRunningRemoteMembers(MultiXactId multi)
|
||||
{
|
||||
MultiXactMember *members;
|
||||
int nmembers;
|
||||
int i;
|
||||
|
||||
nmembers = GetMultiXactIdMembers(multi, &members, true);
|
||||
if (nmembers <= 0)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < nmembers; i++)
|
||||
{
|
||||
/* not interested in our own members */
|
||||
if (TransactionIdIsCurrentTransactionId(members[i].xid))
|
||||
continue;
|
||||
|
||||
if (TransactionIdIsInProgress(members[i].xid))
|
||||
{
|
||||
pfree(members);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
pfree(members);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* mxactMemberComparator
|
||||
* qsort comparison function for MultiXactMember
|
||||
|
Reference in New Issue
Block a user