228 #define TargetTagIsCoveredBy(covered_target, covering_target) \ 229 ((GET_PREDICATELOCKTARGETTAG_RELATION(covered_target) == \ 230 GET_PREDICATELOCKTARGETTAG_RELATION(covering_target)) \ 231 && (GET_PREDICATELOCKTARGETTAG_OFFSET(covering_target) == \ 232 InvalidOffsetNumber) \ 233 && (((GET_PREDICATELOCKTARGETTAG_OFFSET(covered_target) != \ 234 InvalidOffsetNumber) \ 235 && (GET_PREDICATELOCKTARGETTAG_PAGE(covering_target) == \ 236 GET_PREDICATELOCKTARGETTAG_PAGE(covered_target))) \ 237 || ((GET_PREDICATELOCKTARGETTAG_PAGE(covering_target) == \ 238 InvalidBlockNumber) \ 239 && (GET_PREDICATELOCKTARGETTAG_PAGE(covered_target) \ 240 != InvalidBlockNumber))) \ 241 && (GET_PREDICATELOCKTARGETTAG_DB(covered_target) == \ 242 GET_PREDICATELOCKTARGETTAG_DB(covering_target))) 251 #define PredicateLockHashPartition(hashcode) \ 252 ((hashcode) % NUM_PREDICATELOCK_PARTITIONS) 253 #define PredicateLockHashPartitionLock(hashcode) \ 254 (&MainLWLockArray[PREDICATELOCK_MANAGER_LWLOCK_OFFSET + \ 255 PredicateLockHashPartition(hashcode)].lock) 256 #define PredicateLockHashPartitionLockByIndex(i) \ 257 (&MainLWLockArray[PREDICATELOCK_MANAGER_LWLOCK_OFFSET + (i)].lock) 259 #define NPREDICATELOCKTARGETENTS() \ 260 mul_size(max_predicate_locks_per_xact, add_size(MaxBackends, max_prepared_xacts)) 262 #define SxactIsOnFinishedList(sxact) (!SHMQueueIsDetached(&((sxact)->finishedLink))) 272 #define SxactIsCommitted(sxact) (((sxact)->flags & SXACT_FLAG_COMMITTED) != 0) 273 #define SxactIsPrepared(sxact) (((sxact)->flags & SXACT_FLAG_PREPARED) != 0) 274 #define SxactIsRolledBack(sxact) (((sxact)->flags & SXACT_FLAG_ROLLED_BACK) != 0) 275 #define SxactIsDoomed(sxact) (((sxact)->flags & SXACT_FLAG_DOOMED) != 0) 276 #define SxactIsReadOnly(sxact) (((sxact)->flags & SXACT_FLAG_READ_ONLY) != 0) 277 #define SxactHasSummaryConflictIn(sxact) (((sxact)->flags & SXACT_FLAG_SUMMARY_CONFLICT_IN) != 0) 278 #define SxactHasSummaryConflictOut(sxact) (((sxact)->flags & SXACT_FLAG_SUMMARY_CONFLICT_OUT) != 0) 284 #define SxactHasConflictOut(sxact) (((sxact)->flags & SXACT_FLAG_CONFLICT_OUT) != 0) 285 #define SxactIsDeferrableWaiting(sxact) (((sxact)->flags & SXACT_FLAG_DEFERRABLE_WAITING) != 0) 286 #define SxactIsROSafe(sxact) (((sxact)->flags & SXACT_FLAG_RO_SAFE) != 0) 287 #define SxactIsROUnsafe(sxact) (((sxact)->flags & SXACT_FLAG_RO_UNSAFE) != 0) 288 #define SxactIsPartiallyReleased(sxact) (((sxact)->flags & SXACT_FLAG_PARTIALLY_RELEASED) != 0) 298 #define PredicateLockTargetTagHashCode(predicatelocktargettag) \ 299 get_hash_value(PredicateLockTargetHash, predicatelocktargettag) 311 #define PredicateLockHashCodeFromTargetHashCode(predicatelocktag, targethash) \ 312 ((targethash) ^ ((uint32) PointerGetDatum((predicatelocktag)->myXact)) \ 313 << LOG2_NUM_PREDICATELOCK_PARTITIONS) 321 #define SerialSlruCtl (&SerialSlruCtlData) 323 #define SERIAL_PAGESIZE BLCKSZ 324 #define SERIAL_ENTRYSIZE sizeof(SerCommitSeqNo) 325 #define SERIAL_ENTRIESPERPAGE (SERIAL_PAGESIZE / SERIAL_ENTRYSIZE) 330 #define SERIAL_MAX_PAGE (MaxTransactionId / SERIAL_ENTRIESPERPAGE) 332 #define SerialNextPage(page) (((page) >= SERIAL_MAX_PAGE) ? 0 : (page) + 1) 334 #define SerialValue(slotno, xid) (*((SerCommitSeqNo *) \ 335 (SerialSlruCtl->shared->page_buffer[slotno] + \ 336 ((((uint32) (xid)) % SERIAL_ENTRIESPERPAGE) * SERIAL_ENTRYSIZE)))) 338 #define SerialPage(xid) (((uint32) (xid)) / SERIAL_ENTRIESPERPAGE) 499 relation->
rd_rel->relkind == RELKIND_MATVIEW);
673 if (conflict->
sxactIn == writer)
699 (
errcode(ERRCODE_OUT_OF_MEMORY),
700 errmsg(
"not enough elements in RWConflictPool to record a read/write conflict"),
701 errhint(
"You might need to run fewer transactions at a time or increase max_connections.")));
717 Assert(roXact != activeXact);
727 (
errcode(ERRCODE_OUT_OF_MEMORY),
728 errmsg(
"not enough elements in RWConflictPool to record a potential read/write conflict"),
729 errhint(
"You might need to run fewer transactions at a time or increase max_connections.")));
780 conflict = nextConflict;
805 #ifdef USE_ASSERT_CHECKING 807 SerialPagePrecedesLogicallyUnitTests(
void)
810 offset = per_page / 2;
820 newestXact = newestPage * per_page + offset;
821 Assert(newestXact / per_page == newestPage);
822 oldestXact = newestXact + 1;
823 oldestXact -= 1U << 31;
824 oldestPage = oldestXact / per_page;
835 headPage = newestPage;
836 targetPage = oldestPage;
853 headPage = oldestPage;
854 targetPage = newestPage;
877 #ifdef USE_ASSERT_CHECKING 878 SerialPagePrecedesLogicallyUnitTests();
925 tailXid = serialControl->
tailXid;
950 serialControl->
headPage = targetPage;
955 while (firstZeroPage != targetPage)
987 headXid = serialControl->
headXid;
988 tailXid = serialControl->
tailXid;
1118 tailPage = serialControl->
headPage;
1156 long max_table_size;
1160 #ifndef EXEC_BACKEND 1178 PredicateLockTargetHash =
ShmemInitHash(
"PREDICATELOCKTARGET hash",
1193 (void)
hash_search(PredicateLockTargetHash, &ScratchTargetTag,
1212 max_table_size *= 2;
1235 max_table_size *= 10;
1257 memset(PredXact->
element, 0, requestSize);
1258 for (i = 0; i < max_table_size; i++)
1309 max_table_size *= 5;
1324 memset(RWConflictPool->
element, 0, requestSize);
1325 for (i = 0; i < max_table_size; i++)
1336 FinishedSerializableTransactions = (
SHM_QUEUE *)
1358 long max_table_size;
1366 max_table_size *= 2;
1378 max_table_size *= 10;
1388 max_table_size *= 5;
1487 for (i = NUM_PREDICATELOCK_PARTITIONS - 1; i >= 0; i--)
1529 FinishedSerializableTransactions,
1604 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
1605 errmsg(
"deferrable snapshot was unsafe; trying a new one")));
1630 int num_written = 0;
1638 if (sxact->
pid == blocked_pid)
1653 while (possibleUnsafeConflict != NULL && num_written < output_size)
1655 output[num_written++] = possibleUnsafeConflict->
sxactOut->
pid;
1658 &possibleUnsafeConflict->
inLink,
1692 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1693 errmsg(
"cannot use serializable mode in a hot standby"),
1694 errdetail(
"\"default_transaction_isolation\" is set to \"serializable\"."),
1695 errhint(
"You can use \"SET default_transaction_isolation = 'repeatable read'\" to change the default.")));
1745 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1746 errmsg(
"a snapshot-importing transaction must not be READ ONLY DEFERRABLE")));
1782 elog(
ERROR,
"cannot establish serializable snapshot during a parallel operation");
1800 #ifdef TEST_SUMMARIZE_SERIAL 1824 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1825 errmsg(
"could not import the requested snapshot"),
1826 errdetail(
"The source process with PID %d is not running anymore.",
1911 MySerializableXact = sxact;
1927 Assert(LocalPredicateLockHash == NULL);
1930 LocalPredicateLockHash =
hash_create(
"Local predicate lock",
1962 MySerializableXact->
topXid = xid;
2007 &targettag, targettaghash,
2011 return (target != NULL);
2098 targettag = *newtargettag;
2103 targettag = parenttag;
2180 Assert(rmtarget == target);
2217 predlocksxactlink = &(predlock->
xactLink);
2223 oldlocktag = predlock->
tag;
2226 oldtargettag = oldtarget->
tag;
2247 Assert(rmpredlock == predlock);
2256 predlock = nextpredlock;
2329 targettag = *reqtag;
2334 targettag = nexttag;
2341 parentlock->
held =
false;
2356 promotiontag = targettag;
2388 parenttag = *targettag;
2396 parenttag = nexttag;
2400 &parenttag, targettaghash,
2408 if (parentlock == NULL)
2428 &parenttag, targettaghash,
2430 Assert(rmlock == parentlock);
2465 targettag, targettaghash,
2469 (
errcode(ERRCODE_OUT_OF_MEMORY),
2470 errmsg(
"out of shared memory"),
2471 errhint(
"You might need to increase max_pred_locks_per_transaction.")));
2484 (
errcode(ERRCODE_OUT_OF_MEMORY),
2485 errmsg(
"out of shared memory"),
2486 errhint(
"You might need to increase max_pred_locks_per_transaction.")));
2529 targettag, targettaghash,
2531 locallock->
held =
true;
2680 predlocktargetlink = &(predlock->
targetLink);
2697 predlock = nextpredlock;
2738 LWLock *oldpartitionLock;
2741 LWLock *newpartitionLock;
2743 bool outOfShmem =
false;
2767 if (oldpartitionLock < newpartitionLock)
2773 else if (oldpartitionLock > newpartitionLock)
2815 newpredlocktag.
myTarget = newtarget;
2833 predlocktargetlink = &(oldpredlock->
targetLink);
2885 || (newpredlock->
tag.
myXact == OldCommittedSxact));
2887 oldpredlock = nextpredlock;
2901 if (oldpartitionLock < newpartitionLock)
2906 else if (oldpartitionLock > newpartitionLock)
2961 uint32 heaptargettaghash;
2976 relId = relation->
rd_id;
2985 heapId = relation->
rd_index->indrelid;
2988 Assert(transfer || !isIndex);
2992 heaptargettaghash = 0;
3022 if (transfer && !isIndex
3037 if (transfer && heaptarget == NULL)
3093 newpredlocktag.
myTarget = heaptarget;
3094 newpredlocktag.
myXact = oldXact;
3118 || (newpredlock->
tag.
myXact == OldCommittedSxact));
3121 oldpredlock = nextpredlock;
3135 for (i = NUM_PREDICATELOCK_PARTITIONS - 1; i >= 0; i--)
3190 Assert(oldblkno != newblkno);
3337 possibleUnsafeConflict;
3349 bool topLevelIsDeclaredReadOnly;
3352 Assert(!(isCommit && isReadOnlySafe));
3355 if (!isReadOnlySafe)
3391 Assert(LocalPredicateLockHash == NULL);
3502 if (!topLevelIsDeclaredReadOnly)
3530 while (possibleUnsafeConflict)
3534 &possibleUnsafeConflict->
inLink,
3538 Assert(MySerializableXact == possibleUnsafeConflict->
sxactIn);
3542 possibleUnsafeConflict = nextConflict;
3591 conflict = nextConflict;
3614 conflict = nextConflict;
3617 if (!topLevelIsDeclaredReadOnly)
3629 while (possibleUnsafeConflict)
3633 &possibleUnsafeConflict->
outLink,
3636 roXact = possibleUnsafeConflict->
sxactIn;
3674 possibleUnsafeConflict = nextConflict;
3685 needToClear =
false;
3731 if (LocalPredicateLockHash != NULL)
3734 LocalPredicateLockHash = NULL;
3755 FinishedSerializableTransactions,
3758 while (finishedSxact)
3813 finishedSxact = nextSxact;
3828 bool canDoPartialCleanup;
3845 if (canDoPartialCleanup)
3853 tag = predlock->
tag;
3855 targettag = target->
tag;
3873 predlock = nextpredlock;
3939 tag = predlock->
tag;
3942 targettag = target->
tag;
3966 (
errcode(ERRCODE_OUT_OF_MEMORY),
3967 errmsg(
"out of shared memory"),
3968 errhint(
"You might need to increase max_pred_locks_per_transaction.")));
3990 predlock = nextpredlock;
4022 conflict = nextConflict;
4040 conflict = nextConflict;
4079 for (i = 0; i < snap->
xcnt; i++)
4081 if (xid == snap->
xip[i])
4098 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4099 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4100 errdetail_internal(
"Reason code: Canceled on identification as a pivot, during conflict out checking."),
4101 errhint(
"The transaction might succeed if retried.")));
4134 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4135 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4136 errdetail_internal(
"Reason code: Canceled on identification as a pivot, during conflict out checking."),
4137 errhint(
"The transaction might succeed if retried.")));
4160 if (conflictCommitSeqNo != 0)
4164 || conflictCommitSeqNo
4167 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4168 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4170 errhint(
"The transaction might succeed if retried.")));
4175 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4176 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4177 errdetail_internal(
"Reason code: Canceled on identification as a pivot, with conflict out to old committed transaction %u.", xid),
4178 errhint(
"The transaction might succeed if retried.")));
4214 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4215 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4217 errhint(
"The transaction might succeed if retried.")));
4283 targettag, targettaghash,
4307 predlocktargetlink = &(predlock->
targetLink);
4314 if (sxact == MySerializableXact)
4329 mypredlock = predlock;
4330 mypredlocktag = predlock->
tag;
4359 predlock = nextpredlock;
4372 if (mypredlock != NULL)
4389 (&mypredlocktag, targettaghash);
4395 if (rmpredlock != NULL)
4397 Assert(rmpredlock == mypredlock);
4407 Assert(rmpredlock == mypredlock);
4418 if (rmpredlock != NULL)
4426 targettag, targettaghash,
4456 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4457 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4458 errdetail_internal(
"Reason code: Canceled on identification as a pivot, during conflict in checking."),
4459 errhint(
"The transaction might succeed if retried.")));
4558 heapId = relation->
rd_id;
4596 if (predlock->
tag.
myXact != MySerializableXact
4602 predlock = nextpredlock;
4608 for (i = NUM_PREDICATELOCK_PARTITIONS - 1; i >= 0; i--)
4623 Assert(reader != writer);
4629 if (reader == OldCommittedSxact)
4631 else if (writer == OldCommittedSxact)
4789 if (MySerializableXact == writer)
4793 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4794 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4795 errdetail_internal(
"Reason code: Canceled on identification as a pivot, during write."),
4796 errhint(
"The transaction might succeed if retried.")));
4803 Assert(MySerializableXact == reader);
4805 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4806 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4808 errhint(
"The transaction might succeed if retried.")));
4848 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4849 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4850 errdetail_internal(
"Reason code: Canceled on identification as a pivot, during commit attempt."),
4851 errhint(
"The transaction might succeed if retried.")));
4858 while (nearConflict)
4871 if (farConflict->
sxactOut == MySerializableXact
4886 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
4887 errmsg(
"could not serialize access due to read/write dependencies among transactions"),
4888 errdetail_internal(
"Reason code: Canceled on commit attempt with conflict in from prepared pivot."),
4889 errhint(
"The transaction might succeed if retried.")));
4942 xactRecord->
xmin = MySerializableXact->
xmin;
4943 xactRecord->
flags = MySerializableXact->
flags;
4953 &record,
sizeof(record));
4976 while (predlock != NULL)
4982 &record,
sizeof(record));
5008 MySerializableXact->
pid = 0;
5011 LocalPredicateLockHash = NULL;
5040 MySerializableXact = sxid->
myXact;
5051 void *recdata,
uint32 len)
5077 (
errcode(ERRCODE_OUT_OF_MEMORY),
5078 errmsg(
"out of shared memory")));
#define GET_PREDICATELOCKTARGETTAG_RELATION(locktag)
void * hash_search_with_hash_value(HTAB *hashp, const void *keyPtr, uint32 hashvalue, HASHACTION action, bool *foundPtr)
#define SxactIsReadOnly(sxact)
static SERIALIZABLEXACT * MySerializableXact
static bool PredicateLockingNeededForRelation(Relation relation)
#define GET_PREDICATELOCKTARGETTAG_PAGE(locktag)
TransactionId finishedBefore
void PostPrepare_PredicateLocks(TransactionId xid)
static void CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag, uint32 targettaghash, SERIALIZABLEXACT *sxact)
void hash_destroy(HTAB *hashp)
#define PredXactListDataSize
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
static bool RWConflictExists(const SERIALIZABLEXACT *reader, const SERIALIZABLEXACT *writer)
struct SERIALIZABLEXID SERIALIZABLEXID
bool LWLockHeldByMeInMode(LWLock *l, LWLockMode mode)
#define SerialValue(slotno, xid)
void SetSerializableTransactionSnapshot(Snapshot snapshot, VirtualTransactionId *sourcevxid, int sourcepid)
static HTAB * PredicateLockTargetHash
int errhint(const char *fmt,...)
#define GET_VXID_FROM_PGPROC(vxid, proc)
static void DeleteLockTarget(PREDICATELOCKTARGET *target, uint32 targettaghash)
#define TransactionIdEquals(id1, id2)
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
static void FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
static void SerialInit(void)
#define SxactHasSummaryConflictIn(sxact)
bool TransactionIdIsCurrentTransactionId(TransactionId xid)
static bool TransferPredicateLocksToNewTarget(PREDICATELOCKTARGETTAG oldtargettag, PREDICATELOCKTARGETTAG newtargettag, bool removeOld)
bool LWLockHeldByMe(LWLock *l)
bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot)
static Snapshot GetSafeSnapshot(Snapshot snapshot)
void AttachSerializableXact(SerializableXactHandle handle)
static void output(uint64 loop_count)
#define NPREDICATELOCKTARGETENTS()
static bool XidIsConcurrent(TransactionId xid)
void PredicateLockRelation(Relation relation, Snapshot snapshot)
static PredXactList PredXact
#define SXACT_FLAG_SUMMARY_CONFLICT_OUT
void SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
TransactionId SxactGlobalXmin
struct SERIALIZABLEXIDTAG SERIALIZABLEXIDTAG
static void RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash)
static bool PredicateLockExists(const PREDICATELOCKTARGETTAG *targettag)
static void CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag)
bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2)
struct PREDICATELOCKTARGET PREDICATELOCKTARGET
union SERIALIZABLEXACT::@108 SeqNo
Size PredicateLockShmemSize(void)
static void ReleasePredicateLocksLocal(void)
struct RWConflictData * RWConflict
#define SET_PREDICATELOCKTARGETTAG_PAGE(locktag, dboid, reloid, blocknum)
static uint32 predicatelock_hash(const void *key, Size keysize)
static void DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
static void ClearOldPredicateLocks(void)
int errcode(int sqlerrcode)
static HTAB * SerializableXidHash
static void ReleaseRWConflict(RWConflict conflict)
static void DropAllPredicateLocksFromTable(Relation relation, bool transfer)
bool PageIsPredicateLocked(Relation relation, BlockNumber blkno)
static SlruCtlData SerialSlruCtlData
long hash_get_num_entries(HTAB *hashp)
SERIALIZABLEXACT * myXact
static bool SerializationNeededForWrite(Relation relation)
void * ShmemAlloc(Size size)
void SHMQueueInsertBefore(SHM_QUEUE *queue, SHM_QUEUE *elem)
void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe)
#define SXACT_FLAG_COMMITTED
#define FirstNormalSerCommitSeqNo
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
#define SET_PREDICATELOCKTARGETTAG_TUPLE(locktag, dboid, reloid, blocknum, offnum)
#define SxactIsPrepared(sxact)
TwoPhasePredicateRecordType type
bool RecoveryInProgress(void)
#define SET_PREDICATELOCKTARGETTAG_RELATION(locktag, dboid, reloid)
LocalTransactionId localTransactionId
#define SxactIsOnFinishedList(sxact)
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid)
static void RemoveScratchTarget(bool lockheld)
Snapshot GetTransactionSnapshot(void)
FullTransactionId nextXid
Size SimpleLruShmemSize(int nslots, int nlsns)
void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns, LWLock *ctllock, const char *subdir, int tranche_id, SyncRequestHandler sync_handler)
PredicateLockData * GetPredicateLockStatusData(void)
void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot)
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
int max_predicate_locks_per_xact
PREDICATELOCKTARGETTAG target
void RegisterTwoPhaseRecord(TwoPhaseRmgrId rmid, uint16 info, const void *data, uint32 len)
int errdetail_internal(const char *fmt,...)
#define XidFromFullTransactionId(x)
void predicatelock_twophase_recover(TransactionId xid, uint16 info, void *recdata, uint32 len)
#define PredicateLockHashPartitionLock(hashcode)
void PreCommit_CheckForSerializationFailure(void)
void LWLockRelease(LWLock *lock)
SERIALIZABLEXACT * sxactIn
void ProcSendSignal(int pid)
union TwoPhasePredicateRecord::@109 data
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
#define SxactIsDoomed(sxact)
static void SetRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
static Snapshot GetSerializableTransactionSnapshotInt(Snapshot snapshot, VirtualTransactionId *sourcevxid, int sourcepid)
#define GET_PREDICATELOCKTARGETTAG_OFFSET(locktag)
bool IsInParallelMode(void)
#define SxactIsRolledBack(sxact)
#define PredicateLockHashCodeFromTargetHashCode(predicatelocktag, targethash)
SHM_QUEUE possibleUnsafeConflicts
bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
#define TWOPHASE_RM_PREDICATELOCK_ID
#define SXACT_FLAG_RO_SAFE
#define FirstNormalTransactionId
static HTAB * PredicateLockHash
static SERIALIZABLEXACT * SavedSerializableXact
static RWConflictPoolHeader RWConflictPool
struct PREDICATELOCK PREDICATELOCK
#define SerialNextPage(page)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
struct PREDICATELOCKTAG PREDICATELOCKTAG
TwoPhasePredicateXactRecord xactRecord
#define InvalidSerializableXact
int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok, TransactionId xid)
static void ReleasePredXact(SERIALIZABLEXACT *sxact)
#define SXACT_FLAG_DEFERRABLE_WAITING
static void OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
struct LOCALPREDICATELOCK LOCALPREDICATELOCK
#define RWConflictDataSize
void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit)
VirtualTransactionId vxid
static SERIALIZABLEXACT * NextPredXact(SERIALIZABLEXACT *sxact)
#define GET_PREDICATELOCKTARGETTAG_TYPE(locktag)
int errdetail(const char *fmt,...)
VariableCache ShmemVariableCache
void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
static void PredicateLockAcquire(const PREDICATELOCKTARGETTAG *targettag)
#define InvalidTransactionId
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
#define SXACT_FLAG_CONFLICT_OUT
#define GET_PREDICATELOCKTARGETTAG_DB(locktag)
#define SXACT_FLAG_PREPARED
#define FirstBootstrapObjectId
uint32 LocalTransactionId
SerCommitSeqNo lastCommitBeforeSnapshot
TransactionId GetTopTransactionIdIfAny(void)
#define SxactIsROSafe(sxact)
#define SxactHasSummaryConflictOut(sxact)
#define IsParallelWorker()
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
#define InvalidSerCommitSeqNo
static void RestoreScratchTarget(bool lockheld)
void TransferPredicateLocksToHeapRelation(Relation relation)
void ProcWaitForSignal(uint32 wait_event_info)
void LWLockInitialize(LWLock *lock, int tranche_id)
PREDICATELOCKTARGETTAG * locktags
static SERIALIZABLEXACT * FirstPredXact(void)
SerCommitSeqNo commitSeqNo
bool SHMQueueEmpty(const SHM_QUEUE *queue)
Size hash_estimate_size(long num_entries, Size entrysize)
static void DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag)
#define RWConflictPoolHeaderDataSize
bool ParallelContextActive(void)
#define SXACT_FLAG_PARTIALLY_RELEASED
SerCommitSeqNo HavePartialClearedThrough
Size mul_size(Size s1, Size s2)
SerCommitSeqNo CanPartialClearThrough
#define PredicateLockTargetTagHashCode(predicatelocktargettag)
static int MaxPredicateChildLocks(const PREDICATELOCKTARGETTAG *tag)
Size add_size(Size s1, Size s2)
Pointer SHMQueueNext(const SHM_QUEUE *queue, const SHM_QUEUE *curElem, Size linkOffset)
void PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot, TransactionId tuple_xid)
int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
SerCommitSeqNo earliestOutConflictCommit
static bool GetParentPredicateLockTag(const PREDICATELOCKTARGETTAG *tag, PREDICATELOCKTARGETTAG *parent)
void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno)
#define IsMVCCSnapshot(snapshot)
void * SerializableXactHandle
#define NUM_SERIAL_BUFFERS
PREDICATELOCKTARGETTAG tag
#define ereport(elevel,...)
bool ShmemAddrIsValid(const void *addr)
#define BlockNumberIsValid(blockNumber)
static bool SerialPagePrecedesLogically(int page1, int page2)
SerCommitSeqNo commitSeqNo
#define SXACT_FLAG_DOOMED
#define RecoverySerCommitSeqNo
#define SxactHasConflictOut(sxact)
static void ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial, bool summarize)
#define Assert(condition)
void AtPrepare_PredicateLocks(void)
Snapshot GetSerializableTransactionSnapshot(Snapshot snapshot)
#define SxactIsDeferrableWaiting(sxact)
struct SerialControlData * SerialControl
static bool CheckAndPromotePredicateLockRequest(const PREDICATELOCKTARGETTAG *reqtag)
#define SetInvalidVirtualTransactionId(vxid)
struct PREDICATELOCKTARGETTAG PREDICATELOCKTARGETTAG
#define SXACT_FLAG_ROLLED_BACK
SerCommitSeqNo prepareSeqNo
Snapshot GetSnapshotData(Snapshot snapshot)
static HTAB * LocalPredicateLockHash
#define InvalidBlockNumber
SerCommitSeqNo LastSxactCommitSeqNo
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
#define ItemPointerGetOffsetNumber(pointer)
void CheckTableForSerializableConflictIn(Relation relation)
void * hash_seq_search(HASH_SEQ_STATUS *status)
SERIALIZABLEXACT * OldCommittedSxact
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
static SERIALIZABLEXACT * OldCommittedSxact
#define RelationUsesLocalBuffers(relation)
#define PredicateLockHashPartitionLockByIndex(i)
#define SxactIsPartiallyReleased(sxact)