*** a/src/backend/storage/lmgr/predicate.c --- b/src/backend/storage/lmgr/predicate.c *************** *** 1436,1443 **** GetSafeSnapshot(Snapshot origSnapshot) * them marked us as conflicted. */ MySerializableXact->flags |= SXACT_FLAG_DEFERRABLE_WAITING; ! while (!(SHMQueueEmpty((SHM_QUEUE *) ! &MySerializableXact->possibleUnsafeConflicts) || SxactIsROUnsafe(MySerializableXact))) { LWLockRelease(SerializableXactHashLock); --- 1436,1442 ---- * them marked us as conflicted. */ MySerializableXact->flags |= SXACT_FLAG_DEFERRABLE_WAITING; ! while (!(SHMQueueEmpty(&MySerializableXact->possibleUnsafeConflicts) || SxactIsROUnsafe(MySerializableXact))) { LWLockRelease(SerializableXactHashLock); *************** *** 3120,3132 **** ReleasePredicateLocks(const bool isCommit) * opposed to 'outLink' for the r/w xacts. */ possibleUnsafeConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->possibleUnsafeConflicts, ! (SHM_QUEUE *) &MySerializableXact->possibleUnsafeConflicts, offsetof(RWConflictData, inLink)); while (possibleUnsafeConflict) { nextConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->possibleUnsafeConflicts, &possibleUnsafeConflict->inLink, offsetof(RWConflictData, inLink)); --- 3119,3131 ---- * opposed to 'outLink' for the r/w xacts. */ possibleUnsafeConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->possibleUnsafeConflicts, ! &MySerializableXact->possibleUnsafeConflicts, offsetof(RWConflictData, inLink)); while (possibleUnsafeConflict) { nextConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->possibleUnsafeConflicts, &possibleUnsafeConflict->inLink, offsetof(RWConflictData, inLink)); *************** *** 3159,3171 **** ReleasePredicateLocks(const bool isCommit) * previously committed transactions. */ conflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->outConflicts, ! (SHM_QUEUE *) &MySerializableXact->outConflicts, offsetof(RWConflictData, outLink)); while (conflict) { nextConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->outConflicts, &conflict->outLink, offsetof(RWConflictData, outLink)); --- 3158,3170 ---- * previously committed transactions. */ conflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->outConflicts, ! &MySerializableXact->outConflicts, offsetof(RWConflictData, outLink)); while (conflict) { nextConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->outConflicts, &conflict->outLink, offsetof(RWConflictData, outLink)); *************** *** 3192,3204 **** ReleasePredicateLocks(const bool isCommit) * we're rolling back, clear them all. */ conflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->inConflicts, ! (SHM_QUEUE *) &MySerializableXact->inConflicts, offsetof(RWConflictData, inLink)); while (conflict) { nextConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->inConflicts, &conflict->inLink, offsetof(RWConflictData, inLink)); --- 3191,3203 ---- * we're rolling back, clear them all. */ conflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->inConflicts, ! &MySerializableXact->inConflicts, offsetof(RWConflictData, inLink)); while (conflict) { nextConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->inConflicts, &conflict->inLink, offsetof(RWConflictData, inLink)); *************** *** 3219,3231 **** ReleasePredicateLocks(const bool isCommit) * up if they are known safe or known unsafe. */ possibleUnsafeConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->possibleUnsafeConflicts, ! (SHM_QUEUE *) &MySerializableXact->possibleUnsafeConflicts, offsetof(RWConflictData, outLink)); while (possibleUnsafeConflict) { nextConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->possibleUnsafeConflicts, &possibleUnsafeConflict->outLink, offsetof(RWConflictData, outLink)); --- 3218,3230 ---- * up if they are known safe or known unsafe. */ possibleUnsafeConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->possibleUnsafeConflicts, ! &MySerializableXact->possibleUnsafeConflicts, offsetof(RWConflictData, outLink)); while (possibleUnsafeConflict) { nextConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->possibleUnsafeConflicts, &possibleUnsafeConflict->outLink, offsetof(RWConflictData, outLink)); *************** *** 3296,3302 **** ReleasePredicateLocks(const bool isCommit) /* Add this to the list of transactions to check for later cleanup. */ if (isCommit) SHMQueueInsertBefore(FinishedSerializableTransactions, ! (SHM_QUEUE *) &(MySerializableXact->finishedLink)); if (!isCommit) ReleaseOneSerializableXact(MySerializableXact, false, false); --- 3295,3301 ---- /* Add this to the list of transactions to check for later cleanup. */ if (isCommit) SHMQueueInsertBefore(FinishedSerializableTransactions, ! &MySerializableXact->finishedLink); if (!isCommit) ReleaseOneSerializableXact(MySerializableXact, false, false); *************** *** 3796,3802 **** CheckForSerializableConflictOut(const bool visible, const Relation relation, errhint("The transaction might succeed if retried."))); if (SxactHasSummaryConflictIn(MySerializableXact) ! || !SHMQueueEmpty((SHM_QUEUE *) &MySerializableXact->inConflicts)) ereport(ERROR, (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), errmsg("could not serialize access due to read/write dependencies among transactions"), --- 3795,3801 ---- errhint("The transaction might succeed if retried."))); if (SxactHasSummaryConflictIn(MySerializableXact) ! || !SHMQueueEmpty(&MySerializableXact->inConflicts)) ereport(ERROR, (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), errmsg("could not serialize access due to read/write dependencies among transactions"), *************** *** 4469,4476 **** PreCommit_CheckForSerializationFailure(void) } nearConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->inConflicts, ! (SHM_QUEUE *) &MySerializableXact->inConflicts, offsetof(RWConflictData, inLink)); while (nearConflict) { --- 4468,4475 ---- } nearConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->inConflicts, ! &MySerializableXact->inConflicts, offsetof(RWConflictData, inLink)); while (nearConflict) { *************** *** 4503,4509 **** PreCommit_CheckForSerializationFailure(void) } nearConflict = (RWConflict) ! SHMQueueNext((SHM_QUEUE *) &MySerializableXact->inConflicts, &nearConflict->inLink, offsetof(RWConflictData, inLink)); } --- 4502,4508 ---- } nearConflict = (RWConflict) ! SHMQueueNext(&MySerializableXact->inConflicts, &nearConflict->inLink, offsetof(RWConflictData, inLink)); } *************** *** 4550,4558 **** AtPrepare_PredicateLocks(void) * outConflicts lists, if they're non-empty we'll represent that by * setting the appropriate summary conflict flags. */ ! if (!SHMQueueEmpty((SHM_QUEUE *) &MySerializableXact->inConflicts)) xactRecord->flags |= SXACT_FLAG_SUMMARY_CONFLICT_IN; ! if (!SHMQueueEmpty((SHM_QUEUE *) &MySerializableXact->outConflicts)) xactRecord->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT; RegisterTwoPhaseRecord(TWOPHASE_RM_PREDICATELOCK_ID, 0, --- 4549,4557 ---- * outConflicts lists, if they're non-empty we'll represent that by * setting the appropriate summary conflict flags. */ ! if (!SHMQueueEmpty(&MySerializableXact->inConflicts)) xactRecord->flags |= SXACT_FLAG_SUMMARY_CONFLICT_IN; ! if (!SHMQueueEmpty(&MySerializableXact->outConflicts)) xactRecord->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT; RegisterTwoPhaseRecord(TWOPHASE_RM_PREDICATELOCK_ID, 0,