PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <sys/stat.h>
#include <unistd.h>
#include "access/subtrans.h"
#include "access/transam.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "catalog/catalog.h"
#include "datatype/timestamp.h"
#include "lib/pairingheap.h"
#include "miscadmin.h"
#include "port/pg_lfind.h"
#include "storage/predicate.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "storage/sinval.h"
#include "storage/sinvaladt.h"
#include "storage/spin.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/old_snapshot.h"
#include "utils/rel.h"
#include "utils/resowner_private.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | ActiveSnapshotElt |
struct | ExportedSnapshot |
struct | SerializedSnapshotData |
Macros | |
#define | SNAPSHOT_EXPORT_DIR "pg_snapshots" |
Typedefs | |
typedef struct ActiveSnapshotElt | ActiveSnapshotElt |
typedef struct ExportedSnapshot | ExportedSnapshot |
typedef struct SerializedSnapshotData | SerializedSnapshotData |
Variables | |
int | old_snapshot_threshold |
volatile OldSnapshotControlData * | oldSnapshotControl |
static SnapshotData | CurrentSnapshotData = {SNAPSHOT_MVCC} |
static SnapshotData | SecondarySnapshotData = {SNAPSHOT_MVCC} |
SnapshotData | CatalogSnapshotData = {SNAPSHOT_MVCC} |
SnapshotData | SnapshotSelfData = {SNAPSHOT_SELF} |
SnapshotData | SnapshotAnyData = {SNAPSHOT_ANY} |
static Snapshot | CurrentSnapshot = NULL |
static Snapshot | SecondarySnapshot = NULL |
static Snapshot | CatalogSnapshot = NULL |
static Snapshot | HistoricSnapshot = NULL |
TransactionId | TransactionXmin = FirstNormalTransactionId |
TransactionId | RecentXmin = FirstNormalTransactionId |
static HTAB * | tuplecid_data = NULL |
static ActiveSnapshotElt * | ActiveSnapshot = NULL |
static ActiveSnapshotElt * | OldestActiveSnapshot = NULL |
static pairingheap | RegisteredSnapshots = {&xmin_cmp, NULL, NULL} |
bool | FirstSnapshotSet = false |
static Snapshot | FirstXactSnapshot = NULL |
static List * | exportedSnapshots = NIL |
typedef struct ActiveSnapshotElt ActiveSnapshotElt |
typedef struct ExportedSnapshot ExportedSnapshot |
typedef struct SerializedSnapshotData SerializedSnapshotData |
bool ActiveSnapshotSet | ( | void | ) |
Definition at line 817 of file snapmgr.c.
References ActiveSnapshot.
Referenced by _SPI_execute_plan(), BuildCachedPlan(), EnsurePortalSnapshotExists(), find_inheritance_children_extended(), ForgetPortalSnapshots(), index_concurrently_build(), pg_plan_query(), PortalRunUtility(), postquel_start(), RelationBuildPartitionDesc(), RelationGetPartitionDesc(), RevalidateCachedQuery(), and vacuum().
|
static |
Definition at line 1666 of file snapmgr.c.
References USECS_PER_MINUTE.
Referenced by GetOldSnapshotFromTimeMapping(), MaintainOldSnapshotTimeMapping(), and TransactionIdLimitedForOldSnapshots().
Definition at line 1025 of file snapmgr.c.
References ActiveSnapshot, ActiveSnapshotElt::as_next, Assert(), CurrentSnapshot, elog(), exportedSnapshots, FirstSnapshotSet, FirstXactSnapshot, InvalidateCatalogSnapshot(), lfirst, MyProc, NIL, OldestActiveSnapshot, pairingheap_is_empty, pairingheap_remove(), pairingheap_reset, SnapshotData::ph_node, SnapshotData::regd_count, RegisteredSnapshots, SecondarySnapshot, ExportedSnapshot::snapfile, ExportedSnapshot::snapshot, SnapshotResetXmin(), WARNING, and PGPROC::xmin.
Referenced by CleanupTransaction(), CommitTransaction(), and PrepareTransaction().
void AtSubAbort_Snapshot | ( | int | level | ) |
Definition at line 989 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshot, ActiveSnapshotElt::as_level, ActiveSnapshotElt::as_next, ActiveSnapshotElt::as_snap, Assert(), FreeSnapshot(), next, OldestActiveSnapshot, pfree(), SnapshotData::regd_count, and SnapshotResetXmin().
Referenced by AbortSubTransaction().
void AtSubCommit_Snapshot | ( | int | level | ) |
Definition at line 968 of file snapmgr.c.
References ActiveSnapshot, ActiveSnapshotElt::as_level, and ActiveSnapshotElt::as_next.
Referenced by CommitSubTransaction().
Definition at line 609 of file snapmgr.c.
References SnapshotData::active_count, Assert(), SnapshotData::copied, InvalidSnapshot, MemoryContextAlloc(), SnapshotData::regd_count, SnapshotData::snapXactCompletionCount, SnapshotData::suboverflowed, SnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, TopTransactionContext, SnapshotData::xcnt, and SnapshotData::xip.
Referenced by ExportSnapshot(), GetTransactionSnapshot(), PushActiveSnapshotWithLevel(), PushCopiedSnapshot(), RegisterSnapshotOnOwner(), and SetTransactionSnapshot().
void DeleteAllExportedSnapshotFiles | ( | void | ) |
Definition at line 1584 of file snapmgr.c.
References AllocateDir(), buf, dirent::d_name, ereport, errcode_for_file_access(), errmsg(), FreeDir(), LOG, MAXPGPATH, ReadDirExtended(), SNAPSHOT_EXPORT_DIR, and snprintf.
Referenced by StartupXLOG().
Definition at line 2123 of file snapmgr.c.
References add_size(), Assert(), InvalidSnapshot, mul_size(), SNAPSHOT_MVCC, SnapshotData::snapshot_type, SnapshotData::suboverflowed, SnapshotData::subxcnt, SnapshotData::takenDuringRecovery, and SnapshotData::xcnt.
Referenced by ExecBitmapHeapEstimate(), index_parallelscan_estimate(), index_parallelscan_initialize(), InitializeParallelDSM(), and table_parallelscan_estimate().
char* ExportSnapshot | ( | Snapshot | snapshot | ) |
Definition at line 1125 of file snapmgr.c.
References AllocateFile(), appendStringInfo(), appendStringInfoString(), PGPROC::backendId, buf, CopySnapshot(), ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, exportedSnapshots, FreeFile(), GetMaxSnapshotSubxidCount(), GetTopTransactionIdIfAny(), i, initStringInfo(), IsSubTransaction(), lappend(), list_length(), PGPROC::lxid, MAXPGPATH, MemoryContextSwitchTo(), MyDatabaseId, MyProc, MyProcPid, pairingheap_add(), palloc(), PG_BINARY_W, SnapshotData::ph_node, pstrdup(), SnapshotData::regd_count, RegisteredSnapshots, ExportedSnapshot::snapfile, ExportedSnapshot::snapshot, SNAPSHOT_EXPORT_DIR, snprintf, SnapshotData::suboverflowed, SnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, TopTransactionContext, TransactionIdIsValid, TransactionIdPrecedes(), xactGetCommittedChildren(), XactIsoLevel, XactReadOnly, SnapshotData::xcnt, SnapshotData::xip, SnapshotData::xmax, and SnapshotData::xmin.
Referenced by pg_export_snapshot(), and SnapBuildExportSnapshot().
|
static |
Definition at line 665 of file snapmgr.c.
References SnapshotData::active_count, Assert(), SnapshotData::copied, pfree(), and SnapshotData::regd_count.
Referenced by AtSubAbort_Snapshot(), PopActiveSnapshot(), and UnregisterSnapshotFromOwner().
Snapshot GetActiveSnapshot | ( | void | ) |
Definition at line 805 of file snapmgr.c.
References ActiveSnapshot, ActiveSnapshotElt::as_snap, and Assert().
Referenced by _SPI_execute_plan(), ATExecDetachPartitionFinalize(), BeginCopyTo(), DoCopyTo(), EnsurePortalSnapshotExists(), ExecCreateTableAs(), ExecParallelGetQueryDesc(), execute_sql_string(), ExecuteQuery(), ExplainOnePlan(), find_inheritance_children_extended(), InitializeParallelDSM(), inv_open(), PerformCursorOpen(), pg_current_snapshot(), pg_export_snapshot(), pgrowlocks(), PortalRunUtility(), PortalStart(), postquel_start(), ProcessQuery(), refresh_matview_datafill(), RelationGetPartitionDesc(), spgvacuumscan(), and SPI_cursor_open_internal().
Definition at line 387 of file snapmgr.c.
References GetNonHistoricCatalogSnapshot(), HistoricSnapshot, and HistoricSnapshotActive().
Referenced by process_settings(), systable_beginscan(), systable_beginscan_ordered(), systable_recheck_tuple(), and table_beginscan_catalog().
Snapshot GetLatestSnapshot | ( | void | ) |
Definition at line 326 of file snapmgr.c.
References Assert(), elog(), ERROR, FirstSnapshotSet, GetSnapshotData(), GetTransactionSnapshot(), HistoricSnapshotActive(), IsInParallelMode(), SecondarySnapshot, and SecondarySnapshotData.
Referenced by AlterDomainNotNull(), asyncQueueReadAllNotifications(), ATRewriteTable(), check_default_partition_contents(), currtid_internal(), IndexCheckExclusion(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_PerformCheck(), ScanSourceDatabasePgClass(), validateDomainConstraint(), and validateForeignKeyConstraint().
Definition at line 409 of file snapmgr.c.
References CatalogSnapshot, CatalogSnapshotData, GetSnapshotData(), InvalidateCatalogSnapshot(), pairingheap_add(), SnapshotData::ph_node, RegisteredSnapshots, RelationHasSysCache(), and RelationInvalidatesSnapshotsOnly().
Referenced by GetCatalogSnapshot(), and ScanPgRelation().
Snapshot GetOldestSnapshot | ( | void | ) |
Definition at line 358 of file snapmgr.c.
References ActiveSnapshotElt::as_snap, InvalidXLogRecPtr, SnapshotData::lsn, OldestActiveSnapshot, pairingheap_container, pairingheap_first(), pairingheap_is_empty, RegisteredSnapshots, and XLogRecPtrIsInvalid.
Referenced by init_toast_snapshot().
|
static |
Definition at line 1752 of file snapmgr.c.
References AlignTimestampToMinuteBoundary(), Assert(), OldSnapshotControlData::count_used, OldSnapshotControlData::head_offset, OldSnapshotControlData::head_timestamp, LW_SHARED, LWLockAcquire(), LWLockRelease(), OLD_SNAPSHOT_TIME_MAP_ENTRIES, oldSnapshotControl, USECS_PER_MINUTE, and OldSnapshotControlData::xid_by_minute.
Referenced by TransactionIdLimitedForOldSnapshots().
TimestampTz GetOldSnapshotThresholdTimestamp | ( | void | ) |
Definition at line 1705 of file snapmgr.c.
References OldSnapshotControlData::mutex_threshold, oldSnapshotControl, SpinLockAcquire, SpinLockRelease, and OldSnapshotControlData::threshold_timestamp.
Referenced by TestForOldSnapshot_impl().
TimestampTz GetSnapshotCurrentTimestamp | ( | void | ) |
Definition at line 1680 of file snapmgr.c.
References OldSnapshotControlData::current_timestamp, GetCurrentTimestamp(), OldSnapshotControlData::mutex_current, now(), oldSnapshotControl, SpinLockAcquire, and SpinLockRelease.
Referenced by GetSnapshotDataInitOldSnapshot(), SnapshotTooOldMagicForTest(), and TransactionIdLimitedForOldSnapshots().
Snapshot GetTransactionSnapshot | ( | void | ) |
Definition at line 251 of file snapmgr.c.
References Assert(), CopySnapshot(), CurrentSnapshot, CurrentSnapshotData, elog(), ERROR, FirstSnapshotSet, FirstXactSnapshot, GetSerializableTransactionSnapshot(), GetSnapshotData(), HistoricSnapshot, HistoricSnapshotActive(), InvalidateCatalogSnapshot(), IsInParallelMode(), IsolationIsSerializable, IsolationUsesXactSnapshot, pairingheap_add(), pairingheap_is_empty, SnapshotData::ph_node, SnapshotData::regd_count, and RegisteredSnapshots.
Referenced by _bt_begin_parallel(), _SPI_execute_plan(), AfterTriggerFireDeferred(), AfterTriggerSetState(), begin_replication_step(), bt_check_every_level(), BuildCachedPlan(), CheckTargetForConflictsIn(), cluster_multiple_rels(), DefineIndex(), EnsurePortalSnapshotExists(), exec_bind_message(), exec_eval_simple_expr(), exec_parse_message(), exec_simple_query(), execute_sql_string(), ExecuteCallStmt(), fmgr_sql(), get_database_list(), get_subscription_list(), GetLatestSnapshot(), HandleFunctionRequest(), heapam_index_build_range_scan(), initialize_worker_spi(), InitializeParallelDSM(), InitPostgres(), LogicalRepSyncTableStart(), pg_get_constraintdef_worker(), PortalRunMulti(), PortalRunUtility(), PortalStart(), ReindexMultipleInternal(), ReindexRelationConcurrently(), RemoveTempRelationsCallback(), RevalidateCachedQuery(), ri_PerformCheck(), SPI_cursor_open_internal(), vacuum(), vacuum_rel(), verify_heapam(), worker_spi_main(), and XidIsConcurrent().
bool HaveRegisteredOrActiveSnapshot | ( | void | ) |
Definition at line 1641 of file snapmgr.c.
References ActiveSnapshot, CatalogSnapshot, pairingheap_is_empty, pairingheap_is_singular, and RegisteredSnapshots.
Referenced by init_toast_snapshot(), and SnapBuildInitialSnapshot().
bool HistoricSnapshotActive | ( | void | ) |
Definition at line 2103 of file snapmgr.c.
References HistoricSnapshot.
Referenced by GetCatalogSnapshot(), GetLatestSnapshot(), GetTransactionSnapshot(), HistoricSnapshotGetTupleCids(), RelationClearRelation(), RelationGetIdentityKeyBitmap(), RelationInitPhysicalAddr(), SetTransactionSnapshot(), and SnapBuildInitialSnapshot().
HTAB* HistoricSnapshotGetTupleCids | ( | void | ) |
Definition at line 2109 of file snapmgr.c.
References Assert(), HistoricSnapshotActive(), and tuplecid_data.
Referenced by HeapTupleSatisfiesHistoricMVCC().
void ImportSnapshot | ( | const char * | idstr | ) |
Definition at line 1396 of file snapmgr.c.
References AllocateFile(), elog(), ereport, errcode(), errmsg(), ERROR, FirstSnapshotSet, FreeFile(), fstat, GetMaxSnapshotSubxidCount(), GetMaxSnapshotXidCount(), GetTopTransactionIdIfAny(), i, InvalidTransactionId, IsolationIsSerializable, IsolationUsesXactSnapshot, IsSubTransaction(), MAXPGPATH, MyDatabaseId, OidIsValid, palloc(), parseIntFromText(), parseVxidFromText(), parseXidFromText(), PG_BINARY_R, SetTransactionSnapshot(), SNAPSHOT_EXPORT_DIR, SNAPSHOT_MVCC, SnapshotData::snapshot_type, snprintf, stat::st_size, SnapshotData::suboverflowed, SnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, TransactionIdIsNormal, VirtualTransactionIdIsValid, XACT_SERIALIZABLE, XactReadOnly, SnapshotData::xcnt, SnapshotData::xip, SnapshotData::xmax, and SnapshotData::xmin.
Referenced by ExecSetVariableStmt().
void InvalidateCatalogSnapshot | ( | void | ) |
Definition at line 457 of file snapmgr.c.
References CatalogSnapshot, pairingheap_remove(), SnapshotData::ph_node, RegisteredSnapshots, and SnapshotResetXmin().
Referenced by AtEOXact_Snapshot(), CopyFrom(), GetNonHistoricCatalogSnapshot(), GetTransactionSnapshot(), InitPostgres(), InvalidateCatalogSnapshotConditionally(), InvalidateSystemCachesExtended(), LocalExecuteInvalidationMessage(), SetTransactionSnapshot(), SnapBuildInitialSnapshot(), and wait_for_relation_state_change().
void InvalidateCatalogSnapshotConditionally | ( | void | ) |
Definition at line 478 of file snapmgr.c.
References ActiveSnapshot, CatalogSnapshot, InvalidateCatalogSnapshot(), pairingheap_is_singular, and RegisteredSnapshots.
Referenced by PostgresMain().
void MaintainOldSnapshotTimeMapping | ( | TimestampTz | whenTaken, |
TransactionId | xmin | ||
) |
Definition at line 1903 of file snapmgr.c.
References AlignTimestampToMinuteBoundary(), Assert(), OldSnapshotControlData::count_used, DEBUG1, elog(), OldSnapshotControlData::head_offset, OldSnapshotControlData::head_timestamp, i, OldSnapshotControlData::latest_xmin, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), OldSnapshotControlData::mutex_latest_xmin, OldSnapshotControlData::next_map_update, old_snapshot_threshold, OLD_SNAPSHOT_TIME_MAP_ENTRIES, oldSnapshotControl, SpinLockAcquire, SpinLockRelease, TransactionIdFollows(), TransactionIdIsNormal, TransactionIdPrecedes(), USECS_PER_MINUTE, and OldSnapshotControlData::xid_by_minute.
Referenced by GetSnapshotDataInitOldSnapshot().
|
static |
|
static |
Definition at line 1366 of file snapmgr.c.
References VirtualTransactionId::backendId, ereport, errcode(), errmsg(), ERROR, filename, and VirtualTransactionId::localTransactionId.
Referenced by ImportSnapshot().
|
static |
Datum pg_export_snapshot | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1301 of file snapmgr.c.
References cstring_to_text(), ExportSnapshot(), GetActiveSnapshot(), and PG_RETURN_TEXT_P.
void PopActiveSnapshot | ( | void | ) |
Definition at line 778 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshot, ActiveSnapshotElt::as_next, ActiveSnapshotElt::as_snap, Assert(), FreeSnapshot(), OldestActiveSnapshot, pfree(), SnapshotData::regd_count, and SnapshotResetXmin().
Referenced by _SPI_execute_plan(), AfterTriggerFireDeferred(), AfterTriggerSetState(), ATExecDetachPartition(), BuildCachedPlan(), cluster_multiple_rels(), DefineIndex(), DoPortalRewind(), end_replication_step(), EndCopyTo(), exec_bind_message(), exec_eval_simple_expr(), exec_parse_message(), exec_simple_query(), ExecCreateTableAs(), execute_sql_string(), ExecuteCallStmt(), ExplainOnePlan(), fmgr_sql(), ForgetPortalSnapshots(), HandleFunctionRequest(), index_drop(), initialize_worker_spi(), LogicalRepSyncTableStart(), movedb(), ParallelWorkerMain(), PersistHoldablePortal(), PortalRunMulti(), PortalRunSelect(), PortalRunUtility(), PortalStart(), refresh_matview_datafill(), ReindexMultipleInternal(), ReindexRelationConcurrently(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), RemoveTempRelationsCallback(), RevalidateCachedQuery(), ShutdownSQLFunction(), vacuum(), vacuum_rel(), and worker_spi_main().
void PushActiveSnapshot | ( | Snapshot | snapshot | ) |
Definition at line 683 of file snapmgr.c.
References GetCurrentTransactionNestLevel(), and PushActiveSnapshotWithLevel().
Referenced by _SPI_execute_plan(), AfterTriggerFireDeferred(), AfterTriggerSetState(), begin_replication_step(), BuildCachedPlan(), cluster_multiple_rels(), DefineIndex(), DoPortalRewind(), exec_bind_message(), exec_eval_simple_expr(), exec_parse_message(), exec_simple_query(), execute_sql_string(), ExecuteCallStmt(), fmgr_sql(), HandleFunctionRequest(), initialize_worker_spi(), LogicalRepSyncTableStart(), ParallelWorkerMain(), PersistHoldablePortal(), PortalRunSelect(), PortalStart(), PushCopiedSnapshot(), ReindexMultipleInternal(), ReindexRelationConcurrently(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), RemoveTempRelationsCallback(), RevalidateCachedQuery(), ShutdownSQLFunction(), vacuum(), vacuum_rel(), and worker_spi_main().
void PushActiveSnapshotWithLevel | ( | Snapshot | snapshot, |
int | snap_level | ||
) |
Definition at line 697 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshot, ActiveSnapshotElt::as_level, ActiveSnapshotElt::as_next, ActiveSnapshotElt::as_snap, Assert(), SnapshotData::copied, CopySnapshot(), CurrentSnapshot, InvalidSnapshot, MemoryContextAlloc(), OldestActiveSnapshot, SecondarySnapshot, and TopTransactionContext.
Referenced by EnsurePortalSnapshotExists(), PortalRunUtility(), and PushActiveSnapshot().
void PushCopiedSnapshot | ( | Snapshot | snapshot | ) |
Definition at line 735 of file snapmgr.c.
References CopySnapshot(), and PushActiveSnapshot().
Referenced by _SPI_execute_plan(), BeginCopyTo(), ExecCreateTableAs(), ExplainOnePlan(), PortalRunMulti(), and refresh_matview_datafill().
Definition at line 829 of file snapmgr.c.
References CurrentResourceOwner, InvalidSnapshot, and RegisterSnapshotOnOwner().
Referenced by _bt_begin_parallel(), AlterDomainNotNull(), asyncQueueReadAllNotifications(), ATRewriteTable(), bt_check_every_level(), check_default_partition_contents(), CreateQueryDesc(), currtid_internal(), DefineIndex(), heapam_index_build_range_scan(), index_beginscan_parallel(), IndexCheckExclusion(), pg_get_constraintdef_worker(), PortalRunMulti(), PortalRunUtility(), process_settings(), ReindexRelationConcurrently(), standard_ExecutorStart(), systable_beginscan(), systable_beginscan_ordered(), table_beginscan_catalog(), table_beginscan_parallel(), table_scan_update_snapshot(), validateDomainConstraint(), and validateForeignKeyConstraint().
Snapshot RegisterSnapshotOnOwner | ( | Snapshot | snapshot, |
ResourceOwner | owner | ||
) |
Definition at line 842 of file snapmgr.c.
References SnapshotData::copied, CopySnapshot(), InvalidSnapshot, pairingheap_add(), SnapshotData::ph_node, SnapshotData::regd_count, RegisteredSnapshots, ResourceOwnerEnlargeSnapshots(), and ResourceOwnerRememberSnapshot().
Referenced by be_lo_open(), and RegisterSnapshot().
Snapshot RestoreSnapshot | ( | char * | start_address | ) |
Definition at line 2206 of file snapmgr.c.
References SnapshotData::active_count, SnapshotData::copied, SerializedSnapshotData::curcid, SnapshotData::curcid, SerializedSnapshotData::lsn, SnapshotData::lsn, MemoryContextAlloc(), SnapshotData::regd_count, SNAPSHOT_MVCC, SnapshotData::snapshot_type, SnapshotData::snapXactCompletionCount, SerializedSnapshotData::suboverflowed, SnapshotData::suboverflowed, SerializedSnapshotData::subxcnt, SnapshotData::subxcnt, SnapshotData::subxip, SerializedSnapshotData::takenDuringRecovery, SnapshotData::takenDuringRecovery, TopTransactionContext, SerializedSnapshotData::whenTaken, SnapshotData::whenTaken, SerializedSnapshotData::xcnt, SnapshotData::xcnt, SnapshotData::xip, SerializedSnapshotData::xmax, SnapshotData::xmax, SerializedSnapshotData::xmin, and SnapshotData::xmin.
Referenced by ExecBitmapHeapInitializeWorker(), index_beginscan_parallel(), ParallelWorkerMain(), and table_beginscan_parallel().
void RestoreTransactionSnapshot | ( | Snapshot | snapshot, |
void * | source_pgproc | ||
) |
Definition at line 2271 of file snapmgr.c.
References InvalidPid, and SetTransactionSnapshot().
Referenced by CreateReplicationSlot(), and ParallelWorkerMain().
void SerializeSnapshot | ( | Snapshot | snapshot, |
char * | start_address | ||
) |
Definition at line 2147 of file snapmgr.c.
References Assert(), SerializedSnapshotData::curcid, SnapshotData::curcid, SerializedSnapshotData::lsn, SnapshotData::lsn, SerializedSnapshotData::suboverflowed, SnapshotData::suboverflowed, SerializedSnapshotData::subxcnt, SnapshotData::subxcnt, SnapshotData::subxip, SerializedSnapshotData::takenDuringRecovery, SnapshotData::takenDuringRecovery, SerializedSnapshotData::whenTaken, SnapshotData::whenTaken, SerializedSnapshotData::xcnt, SnapshotData::xcnt, SnapshotData::xip, SerializedSnapshotData::xmax, SnapshotData::xmax, SerializedSnapshotData::xmin, and SnapshotData::xmin.
Referenced by ExecBitmapHeapInitializeDSM(), index_parallelscan_initialize(), InitializeParallelDSM(), and table_parallelscan_initialize().
void SetOldSnapshotThresholdTimestamp | ( | TimestampTz | ts, |
TransactionId | xlimit | ||
) |
Definition at line 1717 of file snapmgr.c.
References Assert(), OldSnapshotControlData::mutex_threshold, oldSnapshotControl, SpinLockAcquire, SpinLockRelease, OldSnapshotControlData::threshold_timestamp, OldSnapshotControlData::threshold_xid, and TransactionIdPrecedesOrEquals().
Referenced by heap_prune_satisfies_vacuum(), and vacuum_get_cutoffs().
|
static |
Definition at line 512 of file snapmgr.c.
References Assert(), CopySnapshot(), CurrentSnapshot, CurrentSnapshotData, ereport, errcode(), errdetail(), errmsg(), ERROR, FirstSnapshotSet, FirstXactSnapshot, GetMaxSnapshotSubxidCount(), GetMaxSnapshotXidCount(), GetSnapshotData(), HistoricSnapshotActive(), InvalidateCatalogSnapshot(), IsolationIsSerializable, IsolationUsesXactSnapshot, pairingheap_add(), pairingheap_is_empty, SnapshotData::ph_node, ProcArrayInstallImportedXmin(), ProcArrayInstallRestoredXmin(), SnapshotData::regd_count, RegisteredSnapshots, SetSerializableTransactionSnapshot(), SnapshotData::snapXactCompletionCount, SnapshotData::suboverflowed, SnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, SnapshotData::xcnt, SnapshotData::xip, SnapshotData::xmax, and SnapshotData::xmin.
Referenced by ImportSnapshot(), and RestoreTransactionSnapshot().
Definition at line 2080 of file snapmgr.c.
References Assert(), HistoricSnapshot, and tuplecid_data.
Referenced by ReorderBufferProcessTXN(), and ReorderBufferQueueMessage().
void SnapMgrInit | ( | void | ) |
Definition at line 214 of file snapmgr.c.
References OldSnapshotControlData::count_used, OldSnapshotControlData::current_timestamp, OldSnapshotControlData::head_offset, OldSnapshotControlData::head_timestamp, InvalidTransactionId, OldSnapshotControlData::latest_xmin, OldSnapshotControlData::mutex_current, OldSnapshotControlData::mutex_latest_xmin, OldSnapshotControlData::mutex_threshold, OldSnapshotControlData::next_map_update, oldSnapshotControl, ShmemInitStruct(), SnapMgrShmemSize(), SpinLockInit, OldSnapshotControlData::threshold_timestamp, and OldSnapshotControlData::threshold_xid.
Referenced by CreateSharedMemoryAndSemaphores().
Size SnapMgrShmemSize | ( | void | ) |
Definition at line 198 of file snapmgr.c.
References add_size(), mul_size(), old_snapshot_threshold, and OLD_SNAPSHOT_TIME_MAP_ENTRIES.
Referenced by CalculateShmemSize(), and SnapMgrInit().
|
static |
Definition at line 944 of file snapmgr.c.
References ActiveSnapshot, InvalidTransactionId, MyProc, pairingheap_container, pairingheap_first(), pairingheap_is_empty, RegisteredSnapshots, TransactionIdPrecedes(), PGPROC::xmin, and SnapshotData::xmin.
Referenced by AtEOXact_Snapshot(), AtSubAbort_Snapshot(), InvalidateCatalogSnapshot(), PopActiveSnapshot(), and UnregisterSnapshotFromOwner().
void SnapshotSetCommandId | ( | CommandId | curcid | ) |
Definition at line 491 of file snapmgr.c.
References SnapshotData::curcid, CurrentSnapshot, FirstSnapshotSet, and SecondarySnapshot.
Referenced by CommandCounterIncrement().
void SnapshotTooOldMagicForTest | ( | void | ) |
Definition at line 1734 of file snapmgr.c.
References Assert(), GetSnapshotCurrentTimestamp(), OldSnapshotControlData::mutex_threshold, old_snapshot_threshold, oldSnapshotControl, SpinLockAcquire, SpinLockRelease, OldSnapshotControlData::threshold_timestamp, and USECS_PER_SEC.
Referenced by heap_page_prune_opt().
void TeardownHistoricSnapshot | ( | bool | is_error | ) |
Definition at line 2096 of file snapmgr.c.
References HistoricSnapshot, and tuplecid_data.
Referenced by ReorderBufferProcessTXN(), and ReorderBufferQueueMessage().
bool ThereAreNoPriorRegisteredSnapshots | ( | void | ) |
Definition at line 1623 of file snapmgr.c.
References pairingheap_is_empty, pairingheap_is_singular, and RegisteredSnapshots.
Referenced by CopyFrom().
bool TransactionIdLimitedForOldSnapshots | ( | TransactionId | recentXmin, |
Relation | relation, | ||
TransactionId * | limit_xid, | ||
TimestampTz * | limit_ts | ||
) |
Definition at line 1796 of file snapmgr.c.
References AlignTimestampToMinuteBoundary(), Assert(), GetOldSnapshotFromTimeMapping(), GetSnapshotCurrentTimestamp(), OldSnapshotControlData::latest_xmin, OldSnapshotControlData::mutex_latest_xmin, OldSnapshotControlData::mutex_threshold, MyProc, OldSnapshotControlData::next_map_update, old_snapshot_threshold, oldSnapshotControl, OldSnapshotThresholdActive(), RelationAllowsEarlyPruning, RelationNeedsWAL, SpinLockAcquire, SpinLockRelease, OldSnapshotControlData::threshold_timestamp, OldSnapshotControlData::threshold_xid, TransactionIdFollows(), TransactionIdFollowsOrEquals(), TransactionIdIsNormal, TransactionIdIsValid, TransactionIdPrecedes(), USECS_PER_MINUTE, USECS_PER_SEC, and PGPROC::xmin.
Referenced by heap_page_prune_opt(), heap_prune_satisfies_vacuum(), and vacuum_get_cutoffs().
void UnregisterSnapshot | ( | Snapshot | snapshot | ) |
Definition at line 871 of file snapmgr.c.
References CurrentResourceOwner, and UnregisterSnapshotFromOwner().
Referenced by _bt_begin_parallel(), _bt_end_parallel(), AlterDomainNotNull(), asyncQueueReadAllNotifications(), ATRewriteTable(), bt_check_every_level(), check_default_partition_contents(), currtid_internal(), DefineIndex(), FreeQueryDesc(), heap_endscan(), heapam_index_build_range_scan(), index_endscan(), IndexCheckExclusion(), pg_get_constraintdef_worker(), process_settings(), ReindexRelationConcurrently(), ResourceOwnerReleaseInternal(), standard_ExecutorEnd(), systable_endscan(), systable_endscan_ordered(), validateDomainConstraint(), and validateForeignKeyConstraint().
void UnregisterSnapshotFromOwner | ( | Snapshot | snapshot, |
ResourceOwner | owner | ||
) |
Definition at line 884 of file snapmgr.c.
References SnapshotData::active_count, Assert(), FreeSnapshot(), pairingheap_is_empty, pairingheap_remove(), SnapshotData::ph_node, SnapshotData::regd_count, RegisteredSnapshots, ResourceOwnerForgetSnapshot(), and SnapshotResetXmin().
Referenced by closeLOfd(), PortalDrop(), PreCommit_Portals(), and UnregisterSnapshot().
void UpdateActiveSnapshotCommandId | ( | void | ) |
Definition at line 747 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshot, ActiveSnapshotElt::as_snap, Assert(), SnapshotData::curcid, elog(), ERROR, GetCurrentCommandId(), IsInParallelMode(), and SnapshotData::regd_count.
Referenced by _SPI_execute_plan(), BeginCopyTo(), ExecCreateTableAs(), ExplainOnePlan(), fmgr_sql(), PortalRunMulti(), and refresh_matview_datafill().
bool XactHasExportedSnapshots | ( | void | ) |
Definition at line 1571 of file snapmgr.c.
References exportedSnapshots, and NIL.
Referenced by PrepareTransaction().
bool XidInMVCCSnapshot | ( | TransactionId | xid, |
Snapshot | snapshot | ||
) |
Definition at line 2287 of file snapmgr.c.
References pg_lfind32(), SnapshotData::suboverflowed, SubTransGetTopmostTransaction(), SnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, TransactionIdFollowsOrEquals(), TransactionIdPrecedes(), SnapshotData::xcnt, SnapshotData::xip, SnapshotData::xmax, and SnapshotData::xmin.
Referenced by asyncQueueProcessPageEntries(), find_inheritance_children_extended(), HeapTupleSatisfiesMVCC(), and RelationGetPartitionDesc().
|
static |
Definition at line 910 of file snapmgr.c.
References a, b, pairingheap_const_container, TransactionIdFollows(), TransactionIdPrecedes(), and SnapshotData::xmin.
|
static |
Definition at line 135 of file snapmgr.c.
Referenced by ActiveSnapshotSet(), AtEOXact_Snapshot(), AtSubAbort_Snapshot(), AtSubCommit_Snapshot(), GetActiveSnapshot(), HaveRegisteredOrActiveSnapshot(), InvalidateCatalogSnapshotConditionally(), PopActiveSnapshot(), PushActiveSnapshotWithLevel(), SnapshotResetXmin(), and UpdateActiveSnapshotCommandId().
|
static |
Definition at line 105 of file snapmgr.c.
Referenced by GetNonHistoricCatalogSnapshot(), HaveRegisteredOrActiveSnapshot(), InvalidateCatalogSnapshot(), and InvalidateCatalogSnapshotConditionally().
SnapshotData CatalogSnapshotData = {SNAPSHOT_MVCC} |
Definition at line 98 of file snapmgr.c.
Referenced by GetNonHistoricCatalogSnapshot().
|
static |
Definition at line 103 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), GetTransactionSnapshot(), PushActiveSnapshotWithLevel(), SetTransactionSnapshot(), and SnapshotSetCommandId().
|
static |
Definition at line 96 of file snapmgr.c.
Referenced by GetTransactionSnapshot(), and SetTransactionSnapshot().
Definition at line 170 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), ExportSnapshot(), and XactHasExportedSnapshots().
Definition at line 150 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), check_transaction_deferrable(), check_transaction_isolation(), check_transaction_read_only(), CreateReplicationSlot(), GetLatestSnapshot(), GetTransactionSnapshot(), ImportSnapshot(), SetTransactionSnapshot(), and SnapshotSetCommandId().
|
static |
Definition at line 157 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), GetTransactionSnapshot(), and SetTransactionSnapshot().
|
static |
Definition at line 106 of file snapmgr.c.
Referenced by GetCatalogSnapshot(), GetTransactionSnapshot(), HistoricSnapshotActive(), SetupHistoricSnapshot(), and TeardownHistoricSnapshot().
int old_snapshot_threshold |
Definition at line 79 of file snapmgr.c.
Referenced by heap_page_prune_opt(), MaintainOldSnapshotTimeMapping(), OldSnapshotThresholdActive(), should_attempt_truncation(), SnapMgrShmemSize(), SnapshotTooOldMagicForTest(), TestForOldSnapshot(), and TransactionIdLimitedForOldSnapshots().
|
static |
Definition at line 138 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), AtSubAbort_Snapshot(), GetOldestSnapshot(), PopActiveSnapshot(), and PushActiveSnapshotWithLevel().
volatile OldSnapshotControlData* oldSnapshotControl |
Definition at line 81 of file snapmgr.c.
Referenced by GetOldSnapshotFromTimeMapping(), GetOldSnapshotThresholdTimestamp(), GetOldSnapshotTimeMapping(), GetSnapshotCurrentTimestamp(), MaintainOldSnapshotTimeMapping(), SetOldSnapshotThresholdTimestamp(), SnapMgrInit(), SnapshotTooOldMagicForTest(), and TransactionIdLimitedForOldSnapshots().
TransactionId RecentXmin = FirstNormalTransactionId |
Definition at line 114 of file snapmgr.c.
Referenced by ATRewriteTables(), bt_check_every_level(), GetSnapshotData(), GetSnapshotDataReuse(), GlobalVisTestFor(), GlobalVisTestShouldUpdate(), GlobalVisUpdateApply(), heap_hot_search_buffer(), heapam_relation_set_new_filelocator(), index_getnext_tid(), refresh_by_heap_swap(), TransactionIdIsActive(), and TransactionIdIsInProgress().
|
static |
Definition at line 147 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), ExportSnapshot(), GetNonHistoricCatalogSnapshot(), GetOldestSnapshot(), GetTransactionSnapshot(), HaveRegisteredOrActiveSnapshot(), InvalidateCatalogSnapshot(), InvalidateCatalogSnapshotConditionally(), RegisterSnapshotOnOwner(), SetTransactionSnapshot(), SnapshotResetXmin(), ThereAreNoPriorRegisteredSnapshots(), and UnregisterSnapshotFromOwner().
|
static |
Definition at line 104 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), GetLatestSnapshot(), PushActiveSnapshotWithLevel(), and SnapshotSetCommandId().
|
static |
Definition at line 97 of file snapmgr.c.
Referenced by GetLatestSnapshot().
SnapshotData SnapshotAnyData = {SNAPSHOT_ANY} |
SnapshotData SnapshotSelfData = {SNAPSHOT_SELF} |
TransactionId TransactionXmin = FirstNormalTransactionId |
Definition at line 113 of file snapmgr.c.
Referenced by BuildCachedPlan(), CheckCachedPlan(), get_relation_info(), GetSnapshotData(), GetSnapshotDataReuse(), heap_abort_speculative(), HeapCheckForSerializableConflictOut(), ProcArrayInstallImportedXmin(), ProcArrayInstallRestoredXmin(), SubTransGetParent(), SubTransGetTopmostTransaction(), TransactionIdDidAbort(), and TransactionIdDidCommit().
|
static |
Definition at line 117 of file snapmgr.c.
Referenced by ApplyLogicalMappingFile(), HistoricSnapshotGetTupleCids(), ResolveCminCmaxDuringDecoding(), SetupHistoricSnapshot(), TeardownHistoricSnapshot(), and UpdateLogicalMappings().