PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "access/commit_ts.h"
#include "access/htup_details.h"
#include "access/subtrans.h"
#include "access/transam.h"
#include "access/twophase.h"
#include "access/twophase_rmgr.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "access/xlogreader.h"
#include "access/xlogrecovery.h"
#include "access/xlogutils.h"
#include "catalog/pg_type.h"
#include "catalog/storage.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "pg_trace.h"
#include "pgstat.h"
#include "replication/origin.h"
#include "replication/syncrep.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/md.h"
#include "storage/predicate.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | GlobalTransactionData |
struct | TwoPhaseStateData |
struct | Working_State |
struct | TwoPhaseRecordOnDisk |
struct | StateFileChunk |
struct | xllist |
Macros | |
#define | TWOPHASE_DIR "pg_twophase" |
#define | TWOPHASE_MAGIC 0x57F94534 /* format identifier */ |
Typedefs | |
typedef struct GlobalTransactionData | GlobalTransactionData |
typedef struct TwoPhaseStateData | TwoPhaseStateData |
typedef xl_xact_prepare | TwoPhaseFileHeader |
typedef struct TwoPhaseRecordOnDisk | TwoPhaseRecordOnDisk |
typedef struct StateFileChunk | StateFileChunk |
Variables | |
int | max_prepared_xacts = 0 |
static TwoPhaseStateData * | TwoPhaseState |
static GlobalTransaction | MyLockedGxact = NULL |
static bool | twophaseExitRegistered = false |
static struct xllist | records |
#define TWOPHASE_DIR "pg_twophase" |
Definition at line 112 of file twophase.c.
#define TWOPHASE_MAGIC 0x57F94534 /* format identifier */ |
Definition at line 989 of file twophase.c.
typedef struct GlobalTransactionData GlobalTransactionData |
typedef struct StateFileChunk StateFileChunk |
typedef xl_xact_prepare TwoPhaseFileHeader |
Definition at line 991 of file twophase.c.
typedef struct TwoPhaseRecordOnDisk TwoPhaseRecordOnDisk |
typedef struct TwoPhaseStateData TwoPhaseStateData |
|
inlinestatic |
Definition at line 936 of file twophase.c.
References Assert, epoch, EpochFromFullTransactionId, FullTransactionIdFromEpochAndXid(), LW_SHARED, LWLockAcquire(), LWLockRelease(), TransamVariablesData::nextXid, TransactionIdIsValid, TransamVariables, unlikely, and XidFromFullTransactionId.
Referenced by TwoPhaseFilePath().
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().
|
static |
Definition at line 294 of file twophase.c.
References AtAbort_Twophase().
Referenced by LockGXact(), and MarkAsPreparing().
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().
|
static |
Definition at line 666 of file twophase.c.
References i, LW_SHARED, LWLockAcquire(), LWLockRelease(), TwoPhaseStateData::numPrepXacts, palloc(), TwoPhaseStateData::prepXacts, and TwoPhaseState.
Referenced by pg_prepared_xact().
|
static |
Definition at line 504 of file twophase.c.
References XidCacheStatus::count, GetPGProcByNumber, XidCacheStatus::overflowed, PGPROC_MAX_CACHED_SUBXIDS, GlobalTransactionData::pgprocno, PGPROC::subxids, PGPROC::subxidStatus, and XidCache::xids.
Referenced by RecoverPreparedTransactions(), and StartPrepare().
Definition at line 2717 of file twophase.c.
References GIDSIZE, and TwoPhaseTransactionGid().
Referenced by LookupGXactBySubid().
|
static |
Definition at line 552 of file twophase.c.
References AtProcExit_Twophase(), before_shmem_exit(), PGPROC::databaseId, ereport, errcode(), errhint(), errmsg(), ERROR, GetPGProcByNumber, GlobalTransactionData::gid, i, INVALID_PROC_NUMBER, GlobalTransactionData::locking_backend, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyDatabaseId, MyLockedGxact, MyProcNumber, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::owner, GlobalTransactionData::pgprocno, TwoPhaseStateData::prepXacts, superuser_arg(), twophaseExitRegistered, TwoPhaseState, user, and GlobalTransactionData::valid.
Referenced by FinishPreparedTransaction().
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().
|
static |
Definition at line 530 of file twophase.c.
References Assert, GetPGProcByNumber, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), GlobalTransactionData::pgprocno, ProcArrayAdd(), and GlobalTransactionData::valid.
Referenced by EndPrepare(), and RecoverPreparedTransactions().
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().
|
static |
Definition at line 433 of file twophase.c.
References AmStartupProcess, Assert, XidCacheStatus::count, PGPROC::databaseId, PGPROC::delayChkptFlags, dlist_init(), dlist_node_init(), GetPGProcByNumber, GlobalTransactionData::gid, i, GlobalTransactionData::inredo, INVALID_PROC_NUMBER, InvalidOid, InvalidTransactionId, PGPROC::isBackgroundWorker, IsPostmasterEnvironment, PGPROC::links, LocalTransactionIdIsValid, GlobalTransactionData::locking_backend, LW_EXCLUSIVE, LW_WS_NOT_WAITING, LWLockHeldByMeInMode(), PGPROC::lwWaiting, PGPROC::lwWaitMode, PGPROC::lxid, MemSet, MyLockedGxact, MyProc, PGPROC::myProcLocks, MyProcNumber, NUM_LOCK_PARTITIONS, XidCacheStatus::overflowed, GlobalTransactionData::owner, pg_atomic_init_u64(), GlobalTransactionData::pgprocno, PGPROC::pid, GlobalTransactionData::prepared_at, PROC_WAIT_STATUS_OK, PGPROC::procNumber, PGPROC::roleId, PGPROC::statusFlags, PGPROC::subxidStatus, PGPROC::tempNamespaceId, GlobalTransactionData::valid, PGPROC::vxid, PGPROC::waitLock, PGPROC::waitProcLock, PGPROC::waitStart, PGPROC::waitStatus, GlobalTransactionData::xid, PGPROC::xid, and PGPROC::xmin.
Referenced by MarkAsPreparing(), and RecoverPreparedTransactions().
Datum pg_prepared_xact | ( | PG_FUNCTION_ARGS | ) |
Definition at line 711 of file twophase.c.
References Working_State::array, BlessTupleDesc(), CreateTemplateTupleDesc(), CStringGetTextDatum, Working_State::currIdx, PGPROC::databaseId, GetPGProcByNumber, GetPreparedTransactionList(), GlobalTransactionData::gid, heap_form_tuple(), HeapTupleGetDatum(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, Working_State::ngxacts, ObjectIdGetDatum(), GlobalTransactionData::owner, palloc(), GlobalTransactionData::pgprocno, GlobalTransactionData::prepared_at, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, TimestampTzGetDatum(), TransactionIdGetDatum(), FuncCallContext::tuple_desc, TupleDescInitEntry(), FuncCallContext::user_fctx, GlobalTransactionData::valid, values, while(), and PGPROC::xid.
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().
|
static |
Definition at line 1696 of file twophase.c.
References Assert, TwoPhaseRecordOnDisk::info, TwoPhaseRecordOnDisk::len, MAXALIGN, TwoPhaseRecordOnDisk::rmid, TWOPHASE_RM_END_ID, and TWOPHASE_RM_MAX_ID.
Referenced by FinishPreparedTransaction(), and RecoverPreparedTransactions().
|
static |
Definition at line 2193 of file twophase.c.
References AdvanceNextFullTransactionIdPastXid(), Assert, buf, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errmsg(), ERROR, xl_xact_prepare::gidlen, i, InvalidXLogRecPtr, LW_EXCLUSIVE, LWLockHeldByMeInMode(), MAXALIGN, TransamVariablesData::nextXid, xl_xact_prepare::nsubxacts, PrepareRedoRemove(), ReadTwoPhaseFile(), RemoveTwoPhaseFile(), SubTransSetParent(), TransactionIdDidAbort(), TransactionIdDidCommit(), TransactionIdEquals, TransactionIdFollows(), TransactionIdFollowsOrEquals(), TransamVariables, WARNING, xl_xact_prepare::xid, XidFromFullTransactionId, and XlogReadTwoPhaseData().
Referenced by PrescanPreparedTransactions(), RecoverPreparedTransactions(), restoreTwoPhaseData(), and StandbyRecoverPreparedTransactions().
|
static |
Definition at line 1303 of file twophase.c.
References buf, CloseTransientFile(), COMP_CRC32C, EQ_CRC32C, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errcode_for_file_access(), errmsg(), errmsg_plural(), ERROR, fd(), FIN_CRC32C, fstat, INIT_CRC32C, xl_xact_prepare::magic, MAXALIGN, MaxAllocSize, MAXPGPATH, OpenTransientFile(), palloc(), PG_BINARY, pgstat_report_wait_end(), pgstat_report_wait_start(), read, stat::st_size, xl_xact_prepare::total_len, TWOPHASE_MAGIC, and TwoPhaseFilePath().
Referenced by FinishPreparedTransaction(), LookupGXact(), ProcessTwoPhaseBuffer(), and StandbyTransactionIdIsPrepared().
|
static |
Definition at line 2411 of file twophase.c.
References DoNotReplicateId, elog, END_CRIT_SECTION, GetCurrentTimestamp(), InvalidRepOriginId, MyXactFlags, PANIC, replorigin_session_advance(), replorigin_session_origin, replorigin_session_origin_lsn, START_CRIT_SECTION, SyncRepWaitForLSN(), TransactionIdAbortTree(), TransactionIdDidCommit(), XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, XactLastRecEnd, XactLogAbortRecord(), and XLogFlush().
Referenced by FinishPreparedTransaction().
|
static |
Definition at line 2313 of file twophase.c.
References Assert, DELAY_CHKPT_START, PGPROC::delayChkptFlags, DoNotReplicateId, END_CRIT_SECTION, GetCurrentTimestamp(), InvalidRepOriginId, MyProc, MyXactFlags, replorigin_session_advance(), replorigin_session_origin, replorigin_session_origin_lsn, replorigin_session_origin_timestamp, START_CRIT_SECTION, SyncRepWaitForLSN(), TransactionIdCommitTree(), TransactionTreeSetCommitTsData(), XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, XactLastRecEnd, XactLogCommitRecord(), and XLogFlush().
Referenced by FinishPreparedTransaction().
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().
|
static |
Definition at line 1743 of file twophase.c.
References CloseTransientFile(), COMP_CRC32C, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), FIN_CRC32C, INIT_CRC32C, len, MAXPGPATH, OpenTransientFile(), PG_BINARY, pg_fsync(), pgstat_report_wait_end(), pgstat_report_wait_start(), TwoPhaseFilePath(), and write.
Referenced by CheckPointTwoPhase().
void RegisterTwoPhaseRecord | ( | TwoPhaseRmgrId | rmid, |
uint16 | info, | ||
const void * | data, | ||
uint32 | len | ||
) |
Definition at line 1280 of file twophase.c.
References data, TwoPhaseRecordOnDisk::info, TwoPhaseRecordOnDisk::len, len, TwoPhaseRecordOnDisk::rmid, and save_state_data().
Referenced by AtPrepare_Locks(), AtPrepare_MultiXact(), AtPrepare_PgStat_Relations(), AtPrepare_PredicateLocks(), and EndPrepare().
|
static |
Definition at line 628 of file twophase.c.
References Assert, elog, ERROR, TwoPhaseStateData::freeGXacts, i, LW_EXCLUSIVE, LWLockHeldByMeInMode(), GlobalTransactionData::next, TwoPhaseStateData::numPrepXacts, TwoPhaseStateData::prepXacts, and TwoPhaseState.
Referenced by AtAbort_Twophase(), FinishPreparedTransaction(), and PrepareRedoRemove().
|
static |
Definition at line 1724 of file twophase.c.
References ereport, errcode_for_file_access(), errmsg(), MAXPGPATH, TwoPhaseFilePath(), and WARNING.
Referenced by FinishPreparedTransaction(), PrepareRedoRemove(), and ProcessTwoPhaseBuffer().
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().
|
static |
Definition at line 1037 of file twophase.c.
References xllist::bytes_free, StateFileChunk::data, data, StateFileChunk::len, len, Max, MAXALIGN, StateFileChunk::next, xllist::num_chunks, palloc(), palloc0(), records, xllist::tail, and xllist::total_len.
Referenced by RegisterTwoPhaseRecord(), and StartPrepare().
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().
|
inlinestatic |
Definition at line 961 of file twophase.c.
References AdjustToFullTransactionId(), EpochFromFullTransactionId, MAXPGPATH, snprintf, TWOPHASE_DIR, and XidFromFullTransactionId.
Referenced by PrepareRedoAdd(), ReadTwoPhaseFile(), RecreateTwoPhaseFile(), and RemoveTwoPhaseFile().
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().
ProcNumber 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().
|
static |
Definition at line 800 of file twophase.c.
References Assert, elog, ERROR, i, InvalidTransactionId, LW_SHARED, LWLockAcquire(), LWLockHeldByMe(), LWLockRelease(), TwoPhaseStateData::numPrepXacts, TwoPhaseStateData::prepXacts, TwoPhaseState, and GlobalTransactionData::xid.
Referenced by TwoPhaseGetDummyProc(), and TwoPhaseGetDummyProcNumber().
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().
|
static |
Definition at line 1420 of file twophase.c.
References buf, ereport, errcode(), errcode_for_file_access(), errdetail(), errmsg(), ERROR, len, LSN_FORMAT_ARGS, palloc(), read_local_xlog_page(), wal_segment_close(), wal_segment_open(), wal_segment_size, XL_ROUTINE, XLOG_XACT_OPMASK, XLOG_XACT_PREPARE, XLogBeginRead(), xlogreader, XLogReaderAllocate(), XLogReaderFree(), XLogReadRecord(), XLogRecGetData, XLogRecGetDataLen, XLogRecGetInfo, and XLogRecGetRmid.
Referenced by CheckPointTwoPhase(), FinishPreparedTransaction(), LookupGXact(), and ProcessTwoPhaseBuffer().
int max_prepared_xacts = 0 |
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().
|
static |
Definition at line 196 of file twophase.c.
Referenced by AtAbort_Twophase(), EndPrepare(), FinishPreparedTransaction(), LockGXact(), MarkAsPreparingGuts(), and PostPrepare_Twophase().
|
static |
Referenced by EndPrepare(), save_state_data(), and StartPrepare().
Definition at line 198 of file twophase.c.
Referenced by LockGXact(), and MarkAsPreparing().
|
static |
Definition at line 188 of file twophase.c.
Referenced by CheckPointTwoPhase(), GetPreparedTransactionList(), LockGXact(), LookupGXact(), LookupGXactBySubid(), MarkAsPreparing(), PrepareRedoAdd(), PrepareRedoRemove(), PrescanPreparedTransactions(), RecoverPreparedTransactions(), RemoveGXact(), StandbyRecoverPreparedTransactions(), TwoPhaseGetGXact(), TwoPhaseGetXidByVirtualXID(), and TwoPhaseShmemInit().