PostgreSQL Source Code
git master
|
#include "access/xact.h"
#include "access/xlogdefs.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
Go to the source code of this file.
Typedefs | |
typedef struct GlobalTransactionData * | GlobalTransaction |
Variables | |
PGDLLIMPORT int | max_prepared_xacts |
typedef struct GlobalTransactionData* GlobalTransaction |
Definition at line 26 of file twophase.h.
void AtAbort_Twophase | ( | void | ) |
Definition at line 304 of file twophase.c.
References INVALID_PROC_NUMBER, GlobalTransactionData::locking_backend, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyLockedGxact, RemoveGXact(), and GlobalTransactionData::valid.
Referenced by AbortTransaction(), and AtProcExit_Twophase().
void CheckPointTwoPhase | ( | XLogRecPtr | redo_horizon | ) |
Definition at line 1823 of file twophase.c.
References buf, ereport, errmsg_plural(), fsync_fname(), i, GlobalTransactionData::inredo, InvalidXLogRecPtr, len, LOG, log_checkpoints, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_prepared_xacts, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, pfree(), GlobalTransactionData::prepare_end_lsn, GlobalTransactionData::prepare_start_lsn, TwoPhaseStateData::prepXacts, RecreateTwoPhaseFile(), TWOPHASE_DIR, TwoPhaseState, GlobalTransactionData::valid, GlobalTransactionData::xid, and XlogReadTwoPhaseData().
Referenced by CheckPointGuts().
void EndPrepare | ( | GlobalTransaction | gxact | ) |
Definition at line 1158 of file twophase.c.
References Assert, StateFileChunk::data, DELAY_CHKPT_START, PGPROC::delayChkptFlags, DoNotReplicateId, END_CRIT_SECTION, ereport, errcode(), errmsg(), ERROR, xllist::head, InvalidRepOriginId, StateFileChunk::len, xl_xact_prepare::magic, MarkAsPrepared(), MaxAllocSize, MyLockedGxact, MyProc, StateFileChunk::next, xllist::num_chunks, xl_xact_prepare::origin_lsn, xl_xact_prepare::origin_timestamp, GlobalTransactionData::prepare_end_lsn, GlobalTransactionData::prepare_start_lsn, ProcLastRecPtr, records, RegisterTwoPhaseRecord(), replorigin_session_advance(), replorigin_session_origin, replorigin_session_origin_lsn, replorigin_session_origin_timestamp, START_CRIT_SECTION, SyncRepWaitForLSN(), xllist::tail, xllist::total_len, xl_xact_prepare::total_len, TWOPHASE_MAGIC, TWOPHASE_RM_END_ID, XLOG_INCLUDE_ORIGIN, XLOG_XACT_PREPARE, XLogBeginInsert(), XLogEnsureRecordSpace(), XLogFlush(), XLogInsert(), XLogRegisterData(), and XLogSetRecordFlags().
Referenced by PrepareTransaction().
void FinishPreparedTransaction | ( | const char * | gid, |
bool | isCommit | ||
) |
Definition at line 1503 of file twophase.c.
References Assert, AtEOXact_PgStat(), buf, DropRelationFiles(), GetPGProcByNumber, GetUserId(), xl_xact_prepare::gidlen, HOLD_INTERRUPTS, xl_xact_prepare::initfileinval, LockGXact(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAXALIGN, MyLockedGxact, xl_xact_prepare::nabortrels, xl_xact_prepare::nabortstats, xl_xact_prepare::ncommitrels, xl_xact_prepare::ncommitstats, xl_xact_prepare::ninvalmsgs, xl_xact_prepare::nsubxacts, GlobalTransactionData::ondisk, pfree(), GlobalTransactionData::pgprocno, pgstat_execute_transactional_drops(), PredicateLockTwoPhaseFinish(), GlobalTransactionData::prepare_start_lsn, ProcArrayRemove(), ProcessRecords(), ReadTwoPhaseFile(), RecordTransactionAbortPrepared(), RecordTransactionCommitPrepared(), RelationCacheInitFilePostInvalidate(), RelationCacheInitFilePreInvalidate(), RemoveGXact(), RemoveTwoPhaseFile(), RESUME_INTERRUPTS, SendSharedInvalidMessages(), TransactionIdEquals, TransactionIdLatest(), twophase_postabort_callbacks, twophase_postcommit_callbacks, GlobalTransactionData::valid, GlobalTransactionData::xid, xl_xact_prepare::xid, and XlogReadTwoPhaseData().
Referenced by apply_handle_commit_prepared(), apply_handle_rollback_prepared(), and standard_ProcessUtility().
bool LookupGXact | ( | const char * | gid, |
XLogRecPtr | prepare_end_lsn, | ||
TimestampTz | origin_prepare_timestamp | ||
) |
Definition at line 2640 of file twophase.c.
References Assert, buf, GlobalTransactionData::gid, i, LW_SHARED, LWLockAcquire(), LWLockRelease(), TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, xl_xact_prepare::origin_lsn, xl_xact_prepare::origin_timestamp, pfree(), GlobalTransactionData::prepare_start_lsn, TwoPhaseStateData::prepXacts, ReadTwoPhaseFile(), TwoPhaseState, GlobalTransactionData::valid, GlobalTransactionData::xid, and XlogReadTwoPhaseData().
Referenced by apply_handle_rollback_prepared().
Definition at line 2749 of file twophase.c.
References GlobalTransactionData::gid, i, IsTwoPhaseTransactionGidForSubid(), LW_SHARED, LWLockAcquire(), LWLockRelease(), TwoPhaseStateData::numPrepXacts, TwoPhaseStateData::prepXacts, TwoPhaseState, and GlobalTransactionData::valid.
Referenced by AlterSubscription().
GlobalTransaction MarkAsPreparing | ( | TransactionId | xid, |
const char * | gid, | ||
TimestampTz | prepared_at, | ||
Oid | owner, | ||
Oid | databaseid | ||
) |
Definition at line 359 of file twophase.c.
References Assert, AtProcExit_Twophase(), before_shmem_exit(), ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errhint(), errmsg(), ERROR, TwoPhaseStateData::freeGXacts, GlobalTransactionData::gid, GIDSIZE, i, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MarkAsPreparingGuts(), max_prepared_xacts, GlobalTransactionData::next, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, TwoPhaseStateData::prepXacts, twophaseExitRegistered, and TwoPhaseState.
Referenced by PrepareTransaction().
void PostPrepare_Twophase | ( | void | ) |
Definition at line 344 of file twophase.c.
References INVALID_PROC_NUMBER, GlobalTransactionData::locking_backend, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), and MyLockedGxact.
Referenced by PrepareTransaction(), and RecoverPreparedTransactions().
void PrepareRedoAdd | ( | char * | buf, |
XLogRecPtr | start_lsn, | ||
XLogRecPtr | end_lsn, | ||
RepOriginId | origin_id | ||
) |
Definition at line 2486 of file twophase.c.
References Assert, buf, DEBUG2, elog, ereport, errcode(), errcode_for_file_access(), errdetail(), errhint(), errmsg(), ERROR, TwoPhaseStateData::freeGXacts, GlobalTransactionData::gid, GlobalTransactionData::inredo, INVALID_PROC_NUMBER, InvalidRepOriginId, GlobalTransactionData::locking_backend, LSN_FORMAT_ARGS, LW_EXCLUSIVE, LWLockHeldByMeInMode(), max_prepared_xacts, MAXALIGN, MAXPGPATH, GlobalTransactionData::next, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, xl_xact_prepare::origin_lsn, GlobalTransactionData::owner, xl_xact_prepare::owner, GlobalTransactionData::prepare_end_lsn, GlobalTransactionData::prepare_start_lsn, GlobalTransactionData::prepared_at, xl_xact_prepare::prepared_at, TwoPhaseStateData::prepXacts, reachedConsistency, RecoveryInProgress(), replorigin_advance(), TwoPhaseFilePath(), TwoPhaseState, GlobalTransactionData::valid, WARNING, GlobalTransactionData::xid, xl_xact_prepare::xid, and XLogRecPtrIsInvalid.
Referenced by restoreTwoPhaseData(), and xact_redo().
void PrepareRedoRemove | ( | TransactionId | xid, |
bool | giveWarning | ||
) |
Definition at line 2588 of file twophase.c.
References Assert, DEBUG2, elog, i, GlobalTransactionData::inredo, LW_EXCLUSIVE, LWLockHeldByMeInMode(), TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, TwoPhaseStateData::prepXacts, RecoveryInProgress(), RemoveGXact(), RemoveTwoPhaseFile(), TwoPhaseState, and GlobalTransactionData::xid.
Referenced by ProcessTwoPhaseBuffer(), and xact_redo().
TransactionId PrescanPreparedTransactions | ( | TransactionId ** | xids_p, |
int * | nxids_p | ||
) |
Definition at line 1969 of file twophase.c.
References Assert, buf, i, GlobalTransactionData::inredo, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), TransamVariablesData::nextXid, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, palloc(), pfree(), GlobalTransactionData::prepare_start_lsn, TwoPhaseStateData::prepXacts, ProcessTwoPhaseBuffer(), repalloc(), TransactionIdPrecedes(), TransamVariables, TwoPhaseState, GlobalTransactionData::xid, and XidFromFullTransactionId.
Referenced by StartupXLOG(), and xlog_redo().
void RecoverPreparedTransactions | ( | void | ) |
Definition at line 2090 of file twophase.c.
References Assert, buf, xl_xact_prepare::database, ereport, errmsg(), xl_xact_prepare::gidlen, GXactLoadSubxactData(), i, InHotStandby, GlobalTransactionData::inredo, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MarkAsPrepared(), MarkAsPreparingGuts(), MAXALIGN, xl_xact_prepare::nabortrels, xl_xact_prepare::nabortstats, xl_xact_prepare::ncommitrels, xl_xact_prepare::ncommitstats, xl_xact_prepare::ninvalmsgs, xl_xact_prepare::nsubxacts, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, xl_xact_prepare::owner, pfree(), PostPrepare_Twophase(), GlobalTransactionData::prepare_start_lsn, xl_xact_prepare::prepared_at, TwoPhaseStateData::prepXacts, ProcessRecords(), ProcessTwoPhaseBuffer(), StandbyReleaseLockTree(), TransactionIdEquals, twophase_recover_callbacks, TwoPhaseState, GlobalTransactionData::xid, and xl_xact_prepare::xid.
Referenced by StartupXLOG().
void restoreTwoPhaseData | ( | void | ) |
Definition at line 1905 of file twophase.c.
References AllocateDir(), buf, dirent::d_name, FreeDir(), FullTransactionIdFromU64(), InvalidRepOriginId, InvalidXLogRecPtr, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), PrepareRedoAdd(), ProcessTwoPhaseBuffer(), ReadDir(), strtou64, TWOPHASE_DIR, and XidFromFullTransactionId.
Referenced by StartupXLOG().
void StandbyRecoverPreparedTransactions | ( | void | ) |
Definition at line 2049 of file twophase.c.
References Assert, buf, i, GlobalTransactionData::inredo, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, pfree(), GlobalTransactionData::prepare_start_lsn, TwoPhaseStateData::prepXacts, ProcessTwoPhaseBuffer(), TwoPhaseState, and GlobalTransactionData::xid.
Referenced by StartupXLOG(), and xlog_redo().
bool StandbyTransactionIdIsPrepared | ( | TransactionId | xid | ) |
Definition at line 1475 of file twophase.c.
References Assert, buf, max_prepared_xacts, pfree(), ReadTwoPhaseFile(), TransactionIdEquals, TransactionIdIsValid, and xl_xact_prepare::xid.
Referenced by KnownAssignedXidsRemovePreceding(), and StandbyReleaseOldLocks().
void StartPrepare | ( | GlobalTransaction | gxact | ) |
Definition at line 1065 of file twophase.c.
References xllist::bytes_free, StateFileChunk::data, xl_xact_prepare::database, PGPROC::databaseId, GetPGProcByNumber, GlobalTransactionData::gid, xl_xact_prepare::gidlen, GXactLoadSubxactData(), xllist::head, xl_xact_prepare::initfileinval, InvalidXLogRecPtr, StateFileChunk::len, xl_xact_prepare::magic, Max, xl_xact_prepare::nabortrels, xl_xact_prepare::nabortstats, xl_xact_prepare::ncommitrels, xl_xact_prepare::ncommitstats, StateFileChunk::next, xl_xact_prepare::ninvalmsgs, xl_xact_prepare::nsubxacts, xllist::num_chunks, xl_xact_prepare::origin_lsn, xl_xact_prepare::origin_timestamp, GlobalTransactionData::owner, xl_xact_prepare::owner, palloc(), palloc0(), pfree(), GlobalTransactionData::pgprocno, pgstat_get_transactional_drops(), GlobalTransactionData::prepared_at, xl_xact_prepare::prepared_at, records, save_state_data(), smgrGetPendingDeletes(), xllist::tail, xllist::total_len, xl_xact_prepare::total_len, TWOPHASE_MAGIC, xactGetCommittedChildren(), xactGetCommittedInvalidationMessages(), GlobalTransactionData::xid, and xl_xact_prepare::xid.
Referenced by PrepareTransaction().
PGPROC* TwoPhaseGetDummyProc | ( | TransactionId | xid, |
bool | lock_held | ||
) |
Definition at line 918 of file twophase.c.
References GetPGProcByNumber, GlobalTransactionData::pgprocno, and TwoPhaseGetGXact().
Referenced by lock_twophase_postcommit(), lock_twophase_recover(), and PostPrepare_Locks().
int TwoPhaseGetDummyProcNumber | ( | TransactionId | xid, |
bool | lock_held | ||
) |
Definition at line 903 of file twophase.c.
References GlobalTransactionData::pgprocno, and TwoPhaseGetGXact().
Referenced by multixact_twophase_postcommit(), multixact_twophase_recover(), and PostPrepare_MultiXact().
TransactionId TwoPhaseGetXidByVirtualXID | ( | VirtualTransactionId | vxid, |
bool * | have_more | ||
) |
Definition at line 852 of file twophase.c.
References Assert, GET_VXID_FROM_PGPROC, GetPGProcByNumber, i, GlobalTransactionData::inredo, InvalidTransactionId, LW_SHARED, LWLockAcquire(), LWLockRelease(), TwoPhaseStateData::numPrepXacts, GlobalTransactionData::pgprocno, TwoPhaseStateData::prepXacts, TwoPhaseState, GlobalTransactionData::valid, VirtualTransactionIdEquals, VirtualTransactionIdIsValid, and GlobalTransactionData::xid.
Referenced by XactLockForVirtualXact().
void TwoPhaseShmemInit | ( | void | ) |
Definition at line 253 of file twophase.c.
References Assert, TwoPhaseStateData::freeGXacts, GetNumberFromPGProc, i, IsUnderPostmaster, max_prepared_xacts, MAXALIGN, GlobalTransactionData::next, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::pgprocno, PreparedXactProcs, ShmemInitStruct(), TwoPhaseShmemSize(), and TwoPhaseState.
Referenced by CreateOrAttachShmemStructs().
Size TwoPhaseShmemSize | ( | void | ) |
Definition at line 237 of file twophase.c.
References add_size(), max_prepared_xacts, MAXALIGN, mul_size(), and size.
Referenced by CalculateShmemSize(), and TwoPhaseShmemInit().
void TwoPhaseTransactionGid | ( | Oid | subid, |
TransactionId | xid, | ||
char * | gid_res, | ||
int | szgid | ||
) |
Definition at line 2699 of file twophase.c.
References Assert, ereport, errcode(), errmsg_internal(), ERROR, OidIsValid, snprintf, and TransactionIdIsValid.
Referenced by apply_handle_commit_prepared(), apply_handle_prepare_internal(), apply_handle_rollback_prepared(), and IsTwoPhaseTransactionGidForSubid().
|
extern |
Definition at line 115 of file twophase.c.
Referenced by CheckPointTwoPhase(), CheckRequiredParameterValues(), GetLockConflicts(), GetSerializableTransactionSnapshotInt(), InitControlFile(), InitProcGlobal(), MarkAsPreparing(), predicatelock_twophase_recover(), PredicateLockShmemInit(), PredicateLockShmemSize(), PrepareRedoAdd(), ProcGlobalShmemSize(), StandbyTransactionIdIsPrepared(), TwoPhaseShmemInit(), TwoPhaseShmemSize(), XactLockForVirtualXact(), and XLogReportParameters().