PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/clog.h"
#include "access/slru.h"
#include "access/transam.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "miscadmin.h"
#include "pg_trace.h"
#include "pgstat.h"
#include "storage/proc.h"
#include "storage/sync.h"
#include "utils/guc_hooks.h"
Go to the source code of this file.
Macros | |
#define | CLOG_BITS_PER_XACT 2 |
#define | CLOG_XACTS_PER_BYTE 4 |
#define | CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE) |
#define | CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1) |
#define | CLOG_MAX_ALLOWED_BUFFERS |
#define | TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) |
#define | TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE) |
#define | TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE) |
#define | CLOG_XACTS_PER_LSN_GROUP 32 /* keep this a power of 2 */ |
#define | CLOG_LSNS_PER_PAGE (CLOG_XACTS_PER_PAGE / CLOG_XACTS_PER_LSN_GROUP) |
#define | GetLSNIndex(slotno, xid) |
#define | THRESHOLD_SUBTRANS_CLOG_OPT 5 |
#define | XactCtl (&XactCtlData) |
Variables | |
static SlruCtlData | XactCtlData |
#define CLOG_LSNS_PER_PAGE (CLOG_XACTS_PER_PAGE / CLOG_XACTS_PER_LSN_GROUP) |
#define CLOG_MAX_ALLOWED_BUFFERS |
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1) |
#define CLOG_XACTS_PER_LSN_GROUP 32 /* keep this a power of 2 */ |
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE) |
#define GetLSNIndex | ( | slotno, | |
xid | |||
) |
#define TransactionIdToBIndex | ( | xid | ) | ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE) |
#define TransactionIdToByte | ( | xid | ) | (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE) |
#define TransactionIdToPgIndex | ( | xid | ) | ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) |
#define XactCtl (&XactCtlData) |
void BootStrapCLOG | ( | void | ) |
Definition at line 833 of file clog.c.
References Assert, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), SimpleLruGetBankLock(), SimpleLruWritePage(), XactCtl, and ZeroCLOGPage().
Referenced by BootStrapXLOG().
void CheckPointCLOG | ( | void | ) |
Definition at line 937 of file clog.c.
References SimpleLruWriteAll(), and XactCtl.
Referenced by CheckPointGuts().
void clog_redo | ( | XLogReaderState * | record | ) |
Definition at line 1107 of file clog.c.
References AdvanceOldestClogXid(), Assert, CLOG_TRUNCATE, CLOG_ZEROPAGE, elog, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), xl_clog_truncate::oldestXact, xl_clog_truncate::pageno, PANIC, SimpleLruGetBankLock(), SimpleLruTruncate(), SimpleLruWritePage(), XactCtl, XLogRecGetData, XLogRecGetInfo, XLogRecHasAnyBlockRefs, XLR_INFO_MASK, and ZeroCLOGPage().
|
static |
Definition at line 1055 of file clog.c.
References CLOG_XACTS_PER_PAGE, FirstNormalTransactionId, and TransactionIdPrecedes().
Referenced by CLOGShmemInit().
|
static |
Definition at line 768 of file clog.c.
References CLOG_MAX_ALLOWED_BUFFERS, Max, Min, SimpleLruAutotuneBuffers(), and transaction_buffers.
Referenced by CLOGShmemInit(), and CLOGShmemSize().
void CLOGShmemInit | ( | void | ) |
Definition at line 787 of file clog.c.
References Assert, buf, CLOG_LSNS_PER_PAGE, CLOG_XACTS_PER_PAGE, CLOGPagePrecedes(), CLOGShmemBuffers(), LWTRANCHE_XACT_BUFFER, LWTRANCHE_XACT_SLRU, PGC_POSTMASTER, PGC_S_DYNAMIC_DEFAULT, PGC_S_OVERRIDE, SetConfigOption(), SimpleLruInit(), SlruPagePrecedesUnitTests, snprintf, SYNC_HANDLER_CLOG, transaction_buffers, and XactCtl.
Referenced by CreateOrAttachShmemStructs().
Size CLOGShmemSize | ( | void | ) |
Definition at line 781 of file clog.c.
References CLOG_LSNS_PER_PAGE, CLOGShmemBuffers(), and SimpleLruShmemSize().
Referenced by CalculateShmemSize().
int clogsyncfiletag | ( | const FileTag * | ftag, |
char * | path | ||
) |
Definition at line 1149 of file clog.c.
References SlruSyncFileTag(), and XactCtl.
void ExtendCLOG | ( | TransactionId | newestXact | ) |
Definition at line 959 of file clog.c.
References FirstNormalTransactionId, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), SimpleLruGetBankLock(), TransactionIdEquals, TransactionIdToPage(), TransactionIdToPgIndex, XactCtl, and ZeroCLOGPage().
Referenced by GetNewTransactionId().
|
static |
Definition at line 257 of file clog.c.
References Assert, i, InvalidTransactionId, TransactionIdSetPageStatus(), and TransactionIdToPage().
Referenced by TransactionIdSetTreeStatus().
void StartupCLOG | ( | void | ) |
Definition at line 877 of file clog.c.
References TransamVariablesData::nextXid, pg_atomic_write_u64(), TransactionIdToPage(), TransamVariables, XactCtl, and XidFromFullTransactionId.
Referenced by StartupXLOG().
|
static |
Definition at line 441 of file clog.c.
References PROC_HDR::allProcs, Assert, PROC_HDR::clogGroupFirst, PGPROC::clogGroupMember, PGPROC::clogGroupMemberLsn, PGPROC::clogGroupMemberPage, PGPROC::clogGroupMemberXid, PGPROC::clogGroupMemberXidStatus, PGPROC::clogGroupNext, XidCacheStatus::count, GetPGProcByNumber, INVALID_PROC_NUMBER, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProc, MyProcNumber, pg_atomic_compare_exchange_u32(), pg_atomic_exchange_u32(), pg_atomic_read_u32(), pg_atomic_write_u32(), pg_write_barrier, PGSemaphoreLock(), PGSemaphoreUnlock(), pgstat_report_wait_end(), pgstat_report_wait_start(), ProcGlobal, PGPROC::sem, SimpleLruGetBankLock(), PGPROC::subxids, PGPROC::subxidStatus, THRESHOLD_SUBTRANS_CLOG_OPT, TransactionIdIsValid, TransactionIdSetPageStatusInternal(), XactCtl, and XidCache::xids.
Referenced by TransactionIdSetPageStatus().
XidStatus TransactionIdGetStatus | ( | TransactionId | xid, |
XLogRecPtr * | lsn | ||
) |
Definition at line 735 of file clog.c.
References CLOG_BITS_PER_XACT, CLOG_XACT_BITMASK, GetLSNIndex, LWLockRelease(), SimpleLruGetBankLock(), SimpleLruReadPage_ReadOnly(), TransactionIdToBIndex, TransactionIdToByte, TransactionIdToPage(), and XactCtl.
Referenced by TransactionIdGetCommitLSN(), and TransactionLogFetch().
|
static |
Definition at line 293 of file clog.c.
References XidCacheStatus::count, LW_EXCLUSIVE, LWLockAcquire(), LWLockConditionalAcquire(), LWLockRelease(), MyProc, PGPROC_MAX_CACHED_SUBXIDS, SimpleLruGetBankLock(), StaticAssertDecl, PGPROC::subxids, PGPROC::subxidStatus, THRESHOLD_SUBTRANS_CLOG_OPT, TransactionGroupUpdateXidStatus(), TransactionIdSetPageStatusInternal(), XactCtl, PGPROC::xid, and XidCache::xids.
Referenced by set_status_by_pages(), and TransactionIdSetTreeStatus().
|
static |
Definition at line 364 of file clog.c.
References Assert, i, LW_EXCLUSIVE, LWLockHeldByMeInMode(), SimpleLruGetBankLock(), SimpleLruReadPage(), TRANSACTION_STATUS_ABORTED, TRANSACTION_STATUS_COMMITTED, TRANSACTION_STATUS_SUB_COMMITTED, TransactionIdIsValid, TransactionIdSetStatusBit(), TransactionIdToPage(), XactCtl, and XLogRecPtrIsInvalid.
Referenced by TransactionGroupUpdateXidStatus(), and TransactionIdSetPageStatus().
|
static |
Definition at line 661 of file clog.c.
References Assert, CLOG_BITS_PER_XACT, CLOG_XACT_BITMASK, GetLSNIndex, InRecovery, LW_EXCLUSIVE, LWLockHeldByMeInMode(), SimpleLruGetBankLock(), TRANSACTION_STATUS_COMMITTED, TRANSACTION_STATUS_IN_PROGRESS, TRANSACTION_STATUS_SUB_COMMITTED, TransactionIdToBIndex, TransactionIdToByte, TransactionIdToPage(), XactCtl, and XLogRecPtrIsInvalid.
Referenced by TransactionIdSetPageStatusInternal().
void TransactionIdSetTreeStatus | ( | TransactionId | xid, |
int | nsubxids, | ||
TransactionId * | subxids, | ||
XidStatus | status, | ||
XLogRecPtr | lsn | ||
) |
Definition at line 183 of file clog.c.
References Assert, i, set_status_by_pages(), TRANSACTION_STATUS_ABORTED, TRANSACTION_STATUS_COMMITTED, TRANSACTION_STATUS_SUB_COMMITTED, TransactionIdSetPageStatus(), and TransactionIdToPage().
Referenced by TransactionIdAbortTree(), TransactionIdAsyncCommitTree(), and TransactionIdCommitTree().
|
inlinestatic |
Definition at line 82 of file clog.c.
References CLOG_XACTS_PER_PAGE.
Referenced by ExtendCLOG(), set_status_by_pages(), StartupCLOG(), TransactionIdGetStatus(), TransactionIdSetPageStatusInternal(), TransactionIdSetStatusBit(), TransactionIdSetTreeStatus(), TrimCLOG(), and TruncateCLOG().
void TrimCLOG | ( | void | ) |
Definition at line 892 of file clog.c.
References CLOG_BITS_PER_XACT, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MemSet, TransamVariablesData::nextXid, SimpleLruGetBankLock(), SimpleLruReadPage(), TransactionIdToBIndex, TransactionIdToByte, TransactionIdToPage(), TransactionIdToPgIndex, TransamVariables, XactCtl, and XidFromFullTransactionId.
Referenced by StartupXLOG().
void TruncateCLOG | ( | TransactionId | oldestXact, |
Oid | oldestxid_datoid | ||
) |
Definition at line 1000 of file clog.c.
References AdvanceOldestClogXid(), SimpleLruTruncate(), SlruScanDirCbReportPresence(), SlruScanDirectory(), TransactionIdToPage(), WriteTruncateXlogRec(), and XactCtl.
Referenced by vac_truncate_clog().
|
static |
Definition at line 1088 of file clog.c.
References CLOG_TRUNCATE, xl_clog_truncate::oldestXact, xl_clog_truncate::oldestXactDb, xl_clog_truncate::pageno, XLogBeginInsert(), XLogFlush(), XLogInsert(), and XLogRegisterData().
Referenced by TruncateCLOG().
|
static |
Definition at line 1074 of file clog.c.
References CLOG_ZEROPAGE, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by ZeroCLOGPage().
|
static |
Definition at line 860 of file clog.c.
References SimpleLruZeroPage(), WriteZeroPageXlogRec(), and XactCtl.
Referenced by BootStrapCLOG(), clog_redo(), and ExtendCLOG().
|
static |