#include "postgres.h"
#include "access/clog.h"
#include "access/subtrans.h"
#include "access/transam.h"
#include "utils/snapmgr.h"
Go to the source code of this file.
void TransactionIdAbortTree | ( | TransactionId | xid, | |
int | nxids, | |||
TransactionId * | xids | |||
) |
Definition at line 290 of file transam.c.
References InvalidXLogRecPtr, TRANSACTION_STATUS_ABORTED, and TransactionIdSetTreeStatus().
Referenced by RecordTransactionAbort(), RecordTransactionAbortPrepared(), and xact_redo_abort().
{ TransactionIdSetTreeStatus(xid, nxids, xids, TRANSACTION_STATUS_ABORTED, InvalidXLogRecPtr); }
void TransactionIdAsyncCommitTree | ( | TransactionId | xid, | |
int | nxids, | |||
TransactionId * | xids, | |||
XLogRecPtr | lsn | |||
) |
Definition at line 272 of file transam.c.
References TRANSACTION_STATUS_COMMITTED, and TransactionIdSetTreeStatus().
Referenced by RecordTransactionCommit(), and xact_redo_commit_internal().
{ TransactionIdSetTreeStatus(xid, nxids, xids, TRANSACTION_STATUS_COMMITTED, lsn); }
void TransactionIdCommitTree | ( | TransactionId | xid, | |
int | nxids, | |||
TransactionId * | xids | |||
) |
Definition at line 260 of file transam.c.
References InvalidXLogRecPtr, TRANSACTION_STATUS_COMMITTED, and TransactionIdSetTreeStatus().
Referenced by RecordTransactionCommit(), RecordTransactionCommitPrepared(), and xact_redo_commit_internal().
{ TransactionIdSetTreeStatus(xid, nxids, xids, TRANSACTION_STATUS_COMMITTED, InvalidXLogRecPtr); }
bool TransactionIdDidAbort | ( | TransactionId | transactionId | ) |
Definition at line 181 of file transam.c.
References elog, SubTransGetParent(), TRANSACTION_STATUS_ABORTED, TRANSACTION_STATUS_SUB_COMMITTED, TransactionIdDidAbort(), TransactionIdIsValid, TransactionIdPrecedes(), TransactionLogFetch(), TransactionXmin, and WARNING.
Referenced by asyncQueueProcessPageEntries(), compute_new_xmax_infomask(), heap_lock_updated_tuple_rec(), heap_update(), MultiXactIdGetUpdateXid(), ProcArrayApplyRecoveryInfo(), RecoverPreparedTransactions(), StandbyAcquireAccessExclusiveLock(), StandbyRecoverPreparedTransactions(), TransactionIdDidAbort(), and TransactionIdIsInProgress().
{ XidStatus xidstatus; xidstatus = TransactionLogFetch(transactionId); /* * If it's marked aborted, it's aborted. */ if (xidstatus == TRANSACTION_STATUS_ABORTED) return true; /* * If it's marked subcommitted, we have to check the parent recursively. * However, if it's older than TransactionXmin, we can't look at * pg_subtrans; instead assume that the parent crashed without cleaning up * its children. */ if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED) { TransactionId parentXid; if (TransactionIdPrecedes(transactionId, TransactionXmin)) return true; parentXid = SubTransGetParent(transactionId); if (!TransactionIdIsValid(parentXid)) { /* see notes in TransactionIdDidCommit */ elog(WARNING, "no pg_subtrans entry for subcommitted XID %u", transactionId); return true; } return TransactionIdDidAbort(parentXid); } /* * It's not aborted. */ return false; }
bool TransactionIdDidCommit | ( | TransactionId | transactionId | ) |
Definition at line 125 of file transam.c.
References elog, SubTransGetParent(), TRANSACTION_STATUS_COMMITTED, TRANSACTION_STATUS_SUB_COMMITTED, TransactionIdDidCommit(), TransactionIdIsValid, TransactionIdPrecedes(), TransactionLogFetch(), TransactionXmin, and WARNING.
Referenced by asyncQueueProcessPageEntries(), compute_new_xmax_infomask(), heap_lock_updated_tuple_rec(), HeapTupleHeaderAdvanceLatestRemovedXid(), HeapTupleHeaderIsOnlyLocked(), HeapTupleSatisfiesDirty(), HeapTupleSatisfiesMVCC(), HeapTupleSatisfiesNow(), HeapTupleSatisfiesSelf(), HeapTupleSatisfiesToast(), HeapTupleSatisfiesUpdate(), HeapTupleSatisfiesVacuum(), MultiXactIdExpand(), ProcArrayApplyRecoveryInfo(), RecordTransactionAbort(), RecordTransactionAbortPrepared(), RecoverPreparedTransactions(), StandbyAcquireAccessExclusiveLock(), StandbyRecoverPreparedTransactions(), TransactionIdDidCommit(), and UpdateXmaxHintBits().
{ XidStatus xidstatus; xidstatus = TransactionLogFetch(transactionId); /* * If it's marked committed, it's committed. */ if (xidstatus == TRANSACTION_STATUS_COMMITTED) return true; /* * If it's marked subcommitted, we have to check the parent recursively. * However, if it's older than TransactionXmin, we can't look at * pg_subtrans; instead assume that the parent crashed without cleaning up * its children. * * Originally we Assert'ed that the result of SubTransGetParent was not * zero. However with the introduction of prepared transactions, there can * be a window just after database startup where we do not have complete * knowledge in pg_subtrans of the transactions after TransactionXmin. * StartupSUBTRANS() has ensured that any missing information will be * zeroed. Since this case should not happen under normal conditions, it * seems reasonable to emit a WARNING for it. */ if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED) { TransactionId parentXid; if (TransactionIdPrecedes(transactionId, TransactionXmin)) return false; parentXid = SubTransGetParent(transactionId); if (!TransactionIdIsValid(parentXid)) { elog(WARNING, "no pg_subtrans entry for subcommitted XID %u", transactionId); return false; } return TransactionIdDidCommit(parentXid); } /* * It's not committed. */ return false; }
bool TransactionIdFollows | ( | TransactionId | id1, | |
TransactionId | id2 | |||
) |
Definition at line 334 of file transam.c.
References TransactionIdIsNormal.
Referenced by convert_xid(), GetConflictingVirtualXIDs(), GetSerializableTransactionSnapshotInt(), heap_page_is_all_visible(), HeapTupleHeaderAdvanceLatestRemovedXid(), lazy_scan_heap(), OldSerXidAdd(), OldSerXidGetMinConflictCommitSeqNo(), OldSerXidSetActiveSerXmin(), predicatelock_twophase_recover(), PrescanPreparedTransactions(), ProcArrayApplyRecoveryInfo(), RecordKnownAssignedTransactionIds(), and StandbyRecoverPreparedTransactions().
{ int32 diff; if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2)) return (id1 > id2); diff = (int32) (id1 - id2); return (diff > 0); }
bool TransactionIdFollowsOrEquals | ( | TransactionId | id1, | |
TransactionId | id2 | |||
) |
Definition at line 349 of file transam.c.
References TransactionIdIsNormal.
Referenced by CheckForSerializableConflictOut(), ForceTransactionIdLimitUpdate(), GetNewTransactionId(), KnownAssignedXidsAdd(), KnownAssignedXidsGetAndSetXmin(), KnownAssignedXidsRemovePreceding(), multixact_redo(), PredicateLockTuple(), PrescanPreparedTransactions(), SetTransactionIdLimit(), StartupXLOG(), SubTransGetParent(), SubTransGetTopmostTransaction(), vacuumLeafPage(), xact_redo_abort(), xact_redo_commit_internal(), XidInMVCCSnapshot(), and XidIsConcurrent().
{ int32 diff; if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2)) return (id1 >= id2); diff = (int32) (id1 - id2); return (diff >= 0); }
XLogRecPtr TransactionIdGetCommitLSN | ( | TransactionId | xid | ) |
Definition at line 402 of file transam.c.
References cachedCommitLSN, cachedFetchXid, TransactionIdEquals, TransactionIdGetStatus(), and TransactionIdIsNormal.
Referenced by SetHintBits().
{ XLogRecPtr result; /* * Currently, all uses of this function are for xids that were just * reported to be committed by TransactionLogFetch, so we expect that * checking TransactionLogFetch's cache will usually succeed and avoid an * extra trip to shared memory. */ if (TransactionIdEquals(xid, cachedFetchXid)) return cachedCommitLSN; /* Special XIDs are always known committed */ if (!TransactionIdIsNormal(xid)) return InvalidXLogRecPtr; /* * Get the transaction status. */ (void) TransactionIdGetStatus(xid, &result); return result; }
bool TransactionIdIsKnownCompleted | ( | TransactionId | transactionId | ) |
Definition at line 238 of file transam.c.
References cachedFetchXid, and TransactionIdEquals.
Referenced by TransactionIdIsInProgress().
{ if (TransactionIdEquals(transactionId, cachedFetchXid)) { /* If it's in the cache at all, it must be completed. */ return true; } return false; }
TransactionId TransactionIdLatest | ( | TransactionId | mainxid, | |
int | nxids, | |||
const TransactionId * | xids | |||
) |
Definition at line 365 of file transam.c.
References TransactionIdPrecedes().
Referenced by FinishPreparedTransaction(), ProcArrayApplyXidAssignment(), RecordTransactionAbort(), RecordTransactionCommit(), xact_redo_abort(), and xact_redo_commit_internal().
{ TransactionId result; /* * In practice it is highly likely that the xids[] array is sorted, and so * we could save some cycles by just taking the last child XID, but this * probably isn't so performance-critical that it's worth depending on * that assumption. But just to show we're not totally stupid, scan the * array back-to-front to avoid useless assignments. */ result = mainxid; while (--nxids >= 0) { if (TransactionIdPrecedes(result, xids[nxids])) result = xids[nxids]; } return result; }
bool TransactionIdPrecedes | ( | TransactionId | id1, | |
TransactionId | id2 | |||
) |
Definition at line 300 of file transam.c.
References TransactionIdIsNormal.
Referenced by _bt_page_recyclable(), CheckForSerializableConflictOut(), CheckTargetForConflictsIn(), CLOGPagePrecedes(), convert_xid(), copy_heap_data(), do_start_worker(), ExpireTreeKnownAssignedTransactionIds(), ExportSnapshot(), get_relation_info(), GetOldestActiveTransactionId(), GetOldestXmin(), GetRunningTransactionData(), GetSnapshotData(), heap_freeze_tuple(), heap_page_is_all_visible(), heap_prune_record_prunable(), heap_tuple_needs_freeze(), HeapTupleHeaderAdvanceLatestRemovedXid(), HeapTupleIsSurelyDead(), HeapTupleSatisfiesVacuum(), KnownAssignedXidsAdd(), KnownAssignedXidsGetAndSetXmin(), KnownAssignedXidsSearch(), lazy_scan_heap(), multixact_redo(), OldSerXidAdd(), OldSerXidGetMinConflictCommitSeqNo(), OldSerXidSetActiveSerXmin(), PrescanPreparedTransactions(), ProcArrayApplyRecoveryInfo(), ProcArrayApplyXidAssignment(), ProcArrayEndTransaction(), ProcArrayRemove(), relation_needs_vacanalyze(), rewrite_heap_tuple(), SetNewSxactGlobalXmin(), SubTransGetTopmostTransaction(), SubTransPagePrecedes(), TransactionIdDidAbort(), TransactionIdDidCommit(), TransactionIdIsActive(), TransactionIdIsCurrentTransactionId(), TransactionIdIsInProgress(), TransactionIdLatest(), vac_truncate_clog(), vac_update_datfrozenxid(), vac_update_relstats(), vacuum_set_xid_limits(), vacuumRedirectAndPlaceholder(), XidCacheRemoveRunningXids(), XidInMVCCSnapshot(), XidIsConcurrent(), and xlog_redo().
{ /* * If either ID is a permanent XID then we can just do unsigned * comparison. If both are normal, do a modulo-2^31 comparison. */ int32 diff; if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2)) return (id1 < id2); diff = (int32) (id1 - id2); return (diff < 0); }
bool TransactionIdPrecedesOrEquals | ( | TransactionId | id1, | |
TransactionId | id2 | |||
) |
Definition at line 319 of file transam.c.
References TransactionIdIsNormal.
Referenced by ClearOldPredicateLocks(), GetCurrentVirtualXIDs(), GetSnapshotData(), KnownAssignedXidsAdd(), lazy_vacuum_rel(), ProcArrayInstallImportedXmin(), ProcessStandbyHSFeedbackMessage(), RecordKnownAssignedTransactionIds(), and TransactionIdIsInProgress().
{ int32 diff; if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2)) return (id1 <= id2); diff = (int32) (id1 - id2); return (diff <= 0); }
static XidStatus TransactionLogFetch | ( | TransactionId | transactionId | ) | [static] |
Definition at line 52 of file transam.c.
References BootstrapTransactionId, cachedCommitLSN, cachedFetchXid, cachedFetchXidStatus, FrozenTransactionId, TRANSACTION_STATUS_IN_PROGRESS, TRANSACTION_STATUS_SUB_COMMITTED, TransactionIdEquals, TransactionIdGetStatus(), and TransactionIdIsNormal.
Referenced by TransactionIdDidAbort(), and TransactionIdDidCommit().
{ XidStatus xidstatus; XLogRecPtr xidlsn; /* * Before going to the commit log manager, check our single item cache to * see if we didn't just check the transaction status a moment ago. */ if (TransactionIdEquals(transactionId, cachedFetchXid)) return cachedFetchXidStatus; /* * Also, check to see if the transaction ID is a permanent one. */ if (!TransactionIdIsNormal(transactionId)) { if (TransactionIdEquals(transactionId, BootstrapTransactionId)) return TRANSACTION_STATUS_COMMITTED; if (TransactionIdEquals(transactionId, FrozenTransactionId)) return TRANSACTION_STATUS_COMMITTED; return TRANSACTION_STATUS_ABORTED; } /* * Get the transaction status. */ xidstatus = TransactionIdGetStatus(transactionId, &xidlsn); /* * Cache it, but DO NOT cache status for unfinished or sub-committed * transactions! We only cache status that is guaranteed not to change. */ if (xidstatus != TRANSACTION_STATUS_IN_PROGRESS && xidstatus != TRANSACTION_STATUS_SUB_COMMITTED) { cachedFetchXid = transactionId; cachedFetchXidStatus = xidstatus; cachedCommitLSN = xidlsn; } return xidstatus; }
XLogRecPtr cachedCommitLSN [static] |
Definition at line 35 of file transam.c.
Referenced by TransactionIdGetCommitLSN(), and TransactionLogFetch().
TransactionId cachedFetchXid = InvalidTransactionId [static] |
Definition at line 33 of file transam.c.
Referenced by TransactionIdGetCommitLSN(), TransactionIdIsKnownCompleted(), and TransactionLogFetch().
XidStatus cachedFetchXidStatus [static] |
Definition at line 34 of file transam.c.
Referenced by TransactionLogFetch().