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 "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 |
#define SNAPSHOT_EXPORT_DIR "pg_snapshots" |
Definition at line 159 of file snapmgr.c.
Referenced by DeleteAllExportedSnapshotFiles(), ExportSnapshot(), and ImportSnapshot().
typedef struct ActiveSnapshotElt ActiveSnapshotElt |
typedef struct ExportedSnapshot ExportedSnapshot |
typedef struct SerializedSnapshotData SerializedSnapshotData |
bool ActiveSnapshotSet | ( | void | ) |
Definition at line 798 of file snapmgr.c.
Referenced by _SPI_commit(), _SPI_execute_plan(), BuildCachedPlan(), index_concurrently_build(), OldSnapshotThresholdActive(), pg_plan_query(), PortalRunUtility(), postquel_start(), RevalidateCachedQuery(), and vacuum().
|
static |
Definition at line 1621 of file snapmgr.c.
References USECS_PER_MINUTE.
Referenced by GetOldSnapshotFromTimeMapping(), MaintainOldSnapshotTimeMapping(), and TransactionIdLimitedForOldSnapshots().
Definition at line 1006 of file snapmgr.c.
References ActiveSnapshotElt::as_next, Assert, elog, FirstSnapshotSet, InvalidateCatalogSnapshot(), lfirst, MyProc, NIL, pairingheap_is_empty, pairingheap_remove(), pairingheap_reset, SnapshotData::ph_node, SnapshotData::regd_count, ExportedSnapshot::snapfile, ExportedSnapshot::snapshot, SnapshotResetXmin(), WARNING, and PGPROC::xmin.
Referenced by CleanupTransaction(), CommitTransaction(), OldSnapshotThresholdActive(), and PrepareTransaction().
void AtSubAbort_Snapshot | ( | int | level | ) |
Definition at line 970 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshotElt::as_level, ActiveSnapshotElt::as_next, ActiveSnapshotElt::as_snap, Assert, FreeSnapshot(), next, pfree(), SnapshotData::regd_count, and SnapshotResetXmin().
Referenced by AbortSubTransaction(), and OldSnapshotThresholdActive().
void AtSubCommit_Snapshot | ( | int | level | ) |
Definition at line 949 of file snapmgr.c.
References ActiveSnapshotElt::as_level, and ActiveSnapshotElt::as_next.
Referenced by CommitSubTransaction(), and OldSnapshotThresholdActive().
Definition at line 606 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(), PushActiveSnapshot(), PushCopiedSnapshot(), RegisterSnapshotOnOwner(), and SetTransactionSnapshot().
void DeleteAllExportedSnapshotFiles | ( | void | ) |
Definition at line 1565 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 OldSnapshotThresholdActive(), and StartupXLOG().
Definition at line 2074 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 1106 of file snapmgr.c.
References AllocateFile(), appendStringInfo(), appendStringInfoString(), PGPROC::backendId, buf, CopySnapshot(), StringInfoData::data, ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, FreeFile(), GetMaxSnapshotSubxidCount(), GetTopTransactionIdIfAny(), i, initStringInfo(), IsSubTransaction(), lappend(), StringInfoData::len, list_length(), PGPROC::lxid, MAXPGPATH, MemoryContextSwitchTo(), MyDatabaseId, MyProc, MyProcPid, pairingheap_add(), palloc(), PG_BINARY_W, SnapshotData::ph_node, pstrdup(), SnapshotData::regd_count, 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 OldSnapshotThresholdActive(), pg_export_snapshot(), and SnapBuildExportSnapshot().
|
static |
Definition at line 662 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 786 of file snapmgr.c.
References ActiveSnapshotElt::as_snap, and Assert.
Referenced by _SPI_execute_plan(), BeginCopyTo(), CopyTo(), ExecCreateTableAs(), ExecParallelGetQueryDesc(), execute_sql_string(), ExecuteQuery(), ExplainOnePlan(), InitializeParallelDSM(), inv_open(), OldSnapshotThresholdActive(), PerformCursorOpen(), pg_current_snapshot(), pg_export_snapshot(), pg_xact_status(), pgrowlocks(), PortalRunUtility(), PortalStart(), postquel_start(), ProcessQuery(), refresh_matview_datafill(), spgvacuumscan(), and SPI_cursor_open_internal().
Definition at line 386 of file snapmgr.c.
References GetNonHistoricCatalogSnapshot(), HistoricSnapshot, and HistoricSnapshotActive().
Referenced by OldSnapshotThresholdActive(), process_settings(), systable_beginscan(), systable_beginscan_ordered(), systable_recheck_tuple(), and table_beginscan_catalog().
Snapshot GetLatestSnapshot | ( | void | ) |
Definition at line 325 of file snapmgr.c.
References Assert, elog, ERROR, FirstSnapshotSet, GetSnapshotData(), GetTransactionSnapshot(), HistoricSnapshotActive(), IsInParallelMode(), and SecondarySnapshot.
Referenced by AlterDomainNotNull(), asyncQueueReadAllNotifications(), ATRewriteTable(), check_default_partition_contents(), currtid_internal(), DefineQueryRewrite(), IndexCheckExclusion(), OldSnapshotThresholdActive(), pgstat_collect_oids(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_PerformCheck(), validateDomainConstraint(), and validateForeignKeyConstraint().
Definition at line 408 of file snapmgr.c.
References CatalogSnapshot, GetSnapshotData(), InvalidateCatalogSnapshot(), pairingheap_add(), SnapshotData::ph_node, RelationHasSysCache(), and RelationInvalidatesSnapshotsOnly().
Referenced by GetCatalogSnapshot(), OldSnapshotThresholdActive(), and ScanPgRelation().
Snapshot GetOldestSnapshot | ( | void | ) |
Definition at line 357 of file snapmgr.c.
References ActiveSnapshotElt::as_snap, InvalidXLogRecPtr, SnapshotData::lsn, pairingheap_container, pairingheap_first(), pairingheap_is_empty, and XLogRecPtrIsInvalid.
Referenced by init_toast_snapshot(), and OldSnapshotThresholdActive().
|
static |
Definition at line 1707 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, USECS_PER_MINUTE, and OldSnapshotControlData::xid_by_minute.
Referenced by TransactionIdLimitedForOldSnapshots().
TimestampTz GetOldSnapshotThresholdTimestamp | ( | void | ) |
Definition at line 1660 of file snapmgr.c.
References OldSnapshotControlData::mutex_threshold, SpinLockAcquire, SpinLockRelease, and OldSnapshotControlData::threshold_timestamp.
Referenced by TestForOldSnapshot_impl().
TimestampTz GetSnapshotCurrentTimestamp | ( | void | ) |
Definition at line 1635 of file snapmgr.c.
References OldSnapshotControlData::current_timestamp, GetCurrentTimestamp(), OldSnapshotControlData::mutex_current, now(), SpinLockAcquire, and SpinLockRelease.
Referenced by GetSnapshotDataInitOldSnapshot(), SnapshotTooOldMagicForTest(), and TransactionIdLimitedForOldSnapshots().
Snapshot GetTransactionSnapshot | ( | void | ) |
Definition at line 250 of file snapmgr.c.
References Assert, CopySnapshot(), CurrentSnapshot, elog, ERROR, FirstSnapshotSet, GetSerializableTransactionSnapshot(), GetSnapshotData(), HistoricSnapshot, HistoricSnapshotActive(), InvalidateCatalogSnapshot(), IsInParallelMode(), IsolationIsSerializable, IsolationUsesXactSnapshot, pairingheap_add(), pairingheap_is_empty, SnapshotData::ph_node, and SnapshotData::regd_count.
Referenced by _bt_begin_parallel(), _SPI_execute_plan(), AfterTriggerFireDeferred(), AfterTriggerSetState(), apply_handle_delete(), apply_handle_insert(), apply_handle_update(), bt_check_every_level(), BuildCachedPlan(), CheckTargetForConflictsIn(), cluster(), DefineIndex(), exec_bind_message(), exec_eval_simple_expr(), exec_parse_message(), exec_simple_query(), exec_stmt_call(), execute_sql_string(), fmgr_sql(), get_database_list(), get_subscription_list(), GetLatestSnapshot(), HandleFunctionRequest(), heapam_index_build_range_scan(), initialize_worker_spi(), InitializeParallelDSM(), InitPostgres(), LogicalRepSyncTableStart(), OldSnapshotThresholdActive(), pg_get_constraintdef_worker(), PortalRunMulti(), PortalRunUtility(), PortalStart(), ReindexMultipleInternal(), ReindexRelationConcurrently(), RememberToFreeTupleDescAtEOX(), RevalidateCachedQuery(), ri_PerformCheck(), SPI_cursor_open_internal(), vacuum(), vacuum_rel(), and XidIsConcurrent().
bool HistoricSnapshotActive | ( | void | ) |
Definition at line 2054 of file snapmgr.c.
Referenced by GetCatalogSnapshot(), GetLatestSnapshot(), GetTransactionSnapshot(), HistoricSnapshotGetTupleCids(), RelationClearRelation(), RelationInitPhysicalAddr(), and SetTransactionSnapshot().
HTAB* HistoricSnapshotGetTupleCids | ( | void | ) |
Definition at line 2060 of file snapmgr.c.
References Assert, HistoricSnapshotActive(), and tuplecid_data.
Referenced by HeapTupleSatisfiesHistoricMVCC().
void ImportSnapshot | ( | const char * | idstr | ) |
Definition at line 1377 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(), and OldSnapshotThresholdActive().
void InvalidateCatalogSnapshot | ( | void | ) |
Definition at line 456 of file snapmgr.c.
References pairingheap_remove(), SnapshotData::ph_node, and SnapshotResetXmin().
Referenced by AtEOXact_Snapshot(), CopyFrom(), GetNonHistoricCatalogSnapshot(), GetTransactionSnapshot(), InitPostgres(), InvalidateCatalogSnapshotConditionally(), InvalidateSystemCaches(), LocalExecuteInvalidationMessage(), OldSnapshotThresholdActive(), SetTransactionSnapshot(), and wait_for_relation_state_change().
void InvalidateCatalogSnapshotConditionally | ( | void | ) |
Definition at line 477 of file snapmgr.c.
References InvalidateCatalogSnapshot(), and pairingheap_is_singular.
Referenced by OldSnapshotThresholdActive(), and PostgresMain().
void MaintainOldSnapshotTimeMapping | ( | TimestampTz | whenTaken, |
TransactionId | xmin | ||
) |
Definition at line 1854 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, SpinLockAcquire, SpinLockRelease, TransactionIdFollows(), TransactionIdIsNormal, TransactionIdPrecedes(), USECS_PER_MINUTE, and OldSnapshotControlData::xid_by_minute.
Referenced by GetSnapshotDataInitOldSnapshot(), and OldSnapshotThresholdActive().
|
static |
|
static |
Definition at line 1347 of file snapmgr.c.
References VirtualTransactionId::backendId, ereport, errcode(), errmsg(), ERROR, and VirtualTransactionId::localTransactionId.
Referenced by ImportSnapshot().
|
static |
Datum pg_export_snapshot | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1282 of file snapmgr.c.
References cstring_to_text(), ExportSnapshot(), GetActiveSnapshot(), and PG_RETURN_TEXT_P.
void PopActiveSnapshot | ( | void | ) |
Definition at line 759 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshotElt::as_next, ActiveSnapshotElt::as_snap, Assert, FreeSnapshot(), pfree(), SnapshotData::regd_count, and SnapshotResetXmin().
Referenced by _SPI_commit(), _SPI_execute_plan(), AfterTriggerFireDeferred(), AfterTriggerSetState(), apply_handle_delete(), apply_handle_insert(), apply_handle_update(), BuildCachedPlan(), cluster(), DefineIndex(), DoPortalRewind(), EndCopyTo(), exec_bind_message(), exec_eval_simple_expr(), exec_parse_message(), exec_simple_query(), exec_stmt_call(), ExecCreateTableAs(), execute_sql_string(), ExplainOnePlan(), fmgr_sql(), HandleFunctionRequest(), index_drop(), initialize_worker_spi(), LogicalRepSyncTableStart(), movedb(), OldSnapshotThresholdActive(), ParallelWorkerMain(), PersistHoldablePortal(), PortalRunMulti(), PortalRunSelect(), PortalRunUtility(), PortalStart(), refresh_matview_datafill(), ReindexMultipleInternal(), ReindexRelationConcurrently(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), RememberToFreeTupleDescAtEOX(), RevalidateCachedQuery(), ShutdownSQLFunction(), vacuum(), and vacuum_rel().
void PushActiveSnapshot | ( | Snapshot | snap | ) |
Definition at line 680 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshot, ActiveSnapshotElt::as_level, ActiveSnapshotElt::as_next, ActiveSnapshotElt::as_snap, Assert, SnapshotData::copied, CopySnapshot(), GetCurrentTransactionNestLevel(), InvalidSnapshot, MemoryContextAlloc(), and TopTransactionContext.
Referenced by _SPI_execute_plan(), AfterTriggerFireDeferred(), AfterTriggerSetState(), apply_handle_delete(), apply_handle_insert(), apply_handle_update(), BuildCachedPlan(), cluster(), DefineIndex(), DoPortalRewind(), exec_bind_message(), exec_eval_simple_expr(), exec_parse_message(), exec_simple_query(), exec_stmt_call(), execute_sql_string(), fmgr_sql(), HandleFunctionRequest(), initialize_worker_spi(), LogicalRepSyncTableStart(), OldSnapshotThresholdActive(), ParallelWorkerMain(), PersistHoldablePortal(), PortalRunSelect(), PortalRunUtility(), PortalStart(), PushCopiedSnapshot(), ReindexMultipleInternal(), ReindexRelationConcurrently(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), RememberToFreeTupleDescAtEOX(), RevalidateCachedQuery(), ShutdownSQLFunction(), vacuum(), and vacuum_rel().
void PushCopiedSnapshot | ( | Snapshot | snapshot | ) |
Definition at line 716 of file snapmgr.c.
References CopySnapshot(), and PushActiveSnapshot().
Referenced by _SPI_execute_plan(), BeginCopyTo(), ExecCreateTableAs(), ExplainOnePlan(), OldSnapshotThresholdActive(), PortalRunMulti(), and refresh_matview_datafill().
Definition at line 810 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(), DefineQueryRewrite(), heapam_index_build_range_scan(), index_beginscan_parallel(), IndexCheckExclusion(), OldSnapshotThresholdActive(), pg_get_constraintdef_worker(), pgstat_collect_oids(), 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 823 of file snapmgr.c.
References SnapshotData::copied, CopySnapshot(), InvalidSnapshot, pairingheap_add(), SnapshotData::ph_node, SnapshotData::regd_count, ResourceOwnerEnlargeSnapshots(), and ResourceOwnerRememberSnapshot().
Referenced by inv_open(), OldSnapshotThresholdActive(), and RegisterSnapshot().
Snapshot RestoreSnapshot | ( | char * | start_address | ) |
Definition at line 2157 of file snapmgr.c.
References SnapshotData::active_count, SnapshotData::copied, SnapshotData::curcid, SerializedSnapshotData::curcid, SerializedSnapshotData::lsn, SnapshotData::lsn, MemoryContextAlloc(), SnapshotData::regd_count, SNAPSHOT_MVCC, SnapshotData::snapshot_type, SnapshotData::snapXactCompletionCount, SnapshotData::suboverflowed, SerializedSnapshotData::suboverflowed, SnapshotData::subxcnt, SerializedSnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, SerializedSnapshotData::takenDuringRecovery, TopTransactionContext, SerializedSnapshotData::whenTaken, SnapshotData::whenTaken, SnapshotData::xcnt, SerializedSnapshotData::xcnt, SnapshotData::xip, SnapshotData::xmax, SerializedSnapshotData::xmax, SnapshotData::xmin, and SerializedSnapshotData::xmin.
Referenced by ExecBitmapHeapInitializeWorker(), index_beginscan_parallel(), ParallelWorkerMain(), and table_beginscan_parallel().
void RestoreTransactionSnapshot | ( | Snapshot | snapshot, |
void * | source_pgproc | ||
) |
Definition at line 2222 of file snapmgr.c.
References InvalidPid, and SetTransactionSnapshot().
Referenced by CreateReplicationSlot(), and ParallelWorkerMain().
void SerializeSnapshot | ( | Snapshot | snapshot, |
char * | start_address | ||
) |
Definition at line 2098 of file snapmgr.c.
References Assert, SnapshotData::curcid, SerializedSnapshotData::curcid, SerializedSnapshotData::lsn, SnapshotData::lsn, SnapshotData::suboverflowed, SerializedSnapshotData::suboverflowed, SnapshotData::subxcnt, SerializedSnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, SerializedSnapshotData::takenDuringRecovery, SerializedSnapshotData::whenTaken, SnapshotData::whenTaken, SnapshotData::xcnt, SerializedSnapshotData::xcnt, SnapshotData::xip, SnapshotData::xmax, SerializedSnapshotData::xmax, SnapshotData::xmin, and SerializedSnapshotData::xmin.
Referenced by ExecBitmapHeapInitializeDSM(), index_parallelscan_initialize(), InitializeParallelDSM(), and table_parallelscan_initialize().
void SetOldSnapshotThresholdTimestamp | ( | TimestampTz | ts, |
TransactionId | xlimit | ||
) |
Definition at line 1672 of file snapmgr.c.
References Assert, OldSnapshotControlData::mutex_threshold, SpinLockAcquire, SpinLockRelease, OldSnapshotControlData::threshold_timestamp, OldSnapshotControlData::threshold_xid, and TransactionIdPrecedesOrEquals().
Referenced by heap_prune_satisfies_vacuum(), OldSnapshotThresholdActive(), and vacuum_set_xid_limits().
|
static |
Definition at line 511 of file snapmgr.c.
References Assert, CopySnapshot(), CurrentSnapshot, ereport, errcode(), errdetail(), errmsg(), ERROR, FirstSnapshotSet, GetMaxSnapshotSubxidCount(), GetMaxSnapshotXidCount(), GetSnapshotData(), HistoricSnapshotActive(), InvalidateCatalogSnapshot(), IsolationIsSerializable, IsolationUsesXactSnapshot, pairingheap_add(), pairingheap_is_empty, SnapshotData::ph_node, ProcArrayInstallImportedXmin(), ProcArrayInstallRestoredXmin(), SnapshotData::regd_count, 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 2031 of file snapmgr.c.
References Assert.
Referenced by ReorderBufferProcessTXN(), and ReorderBufferQueueMessage().
void SnapMgrInit | ( | void | ) |
Definition at line 213 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, ShmemInitStruct(), SnapMgrShmemSize(), SpinLockInit, OldSnapshotControlData::threshold_timestamp, and OldSnapshotControlData::threshold_xid.
Referenced by CreateSharedMemoryAndSemaphores().
Size SnapMgrShmemSize | ( | void | ) |
Definition at line 197 of file snapmgr.c.
References add_size(), mul_size(), offsetof, old_snapshot_threshold, and OLD_SNAPSHOT_TIME_MAP_ENTRIES.
Referenced by CreateSharedMemoryAndSemaphores(), and SnapMgrInit().
|
static |
Definition at line 925 of file snapmgr.c.
References InvalidTransactionId, MyProc, pairingheap_container, pairingheap_first(), pairingheap_is_empty, TransactionIdPrecedes(), PGPROC::xmin, and SnapshotData::xmin.
Referenced by AtEOXact_Snapshot(), AtSubAbort_Snapshot(), InvalidateCatalogSnapshot(), PopActiveSnapshot(), and UnregisterSnapshotFromOwner().
void SnapshotSetCommandId | ( | CommandId | curcid | ) |
Definition at line 490 of file snapmgr.c.
References SnapshotData::curcid, and FirstSnapshotSet.
Referenced by CommandCounterIncrement(), and OldSnapshotThresholdActive().
void SnapshotTooOldMagicForTest | ( | void | ) |
Definition at line 1689 of file snapmgr.c.
References Assert, GetSnapshotCurrentTimestamp(), OldSnapshotControlData::mutex_threshold, old_snapshot_threshold, SpinLockAcquire, SpinLockRelease, OldSnapshotControlData::threshold_timestamp, and USECS_PER_SEC.
Referenced by heap_page_prune_opt().
void TeardownHistoricSnapshot | ( | bool | is_error | ) |
Definition at line 2047 of file snapmgr.c.
Referenced by ReorderBufferProcessTXN(), and ReorderBufferQueueMessage().
bool ThereAreNoPriorRegisteredSnapshots | ( | void | ) |
Definition at line 1604 of file snapmgr.c.
References pairingheap_is_empty, and pairingheap_is_singular.
Referenced by CopyFrom(), and OldSnapshotThresholdActive().
bool TransactionIdLimitedForOldSnapshots | ( | TransactionId | recentXmin, |
Relation | relation, | ||
TransactionId * | limit_xid, | ||
TimestampTz * | limit_ts | ||
) |
Definition at line 1751 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, OldSnapshotThresholdActive(), RelationAllowsEarlyPruning, 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(), OldSnapshotThresholdActive(), and vacuum_set_xid_limits().
void UnregisterSnapshot | ( | Snapshot | snapshot | ) |
Definition at line 852 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(), DefineQueryRewrite(), FreeQueryDesc(), heap_endscan(), heapam_index_build_range_scan(), index_endscan(), IndexCheckExclusion(), OldSnapshotThresholdActive(), pg_get_constraintdef_worker(), pgstat_collect_oids(), process_settings(), ReindexRelationConcurrently(), ResourceOwnerReleaseInternal(), standard_ExecutorEnd(), systable_endscan(), systable_endscan_ordered(), validateDomainConstraint(), and validateForeignKeyConstraint().
void UnregisterSnapshotFromOwner | ( | Snapshot | snapshot, |
ResourceOwner | owner | ||
) |
Definition at line 865 of file snapmgr.c.
References SnapshotData::active_count, Assert, FreeSnapshot(), pairingheap_is_empty, pairingheap_remove(), SnapshotData::ph_node, SnapshotData::regd_count, ResourceOwnerForgetSnapshot(), and SnapshotResetXmin().
Referenced by inv_close(), OldSnapshotThresholdActive(), PortalDrop(), PreCommit_Portals(), and UnregisterSnapshot().
void UpdateActiveSnapshotCommandId | ( | void | ) |
Definition at line 728 of file snapmgr.c.
References SnapshotData::active_count, ActiveSnapshotElt::as_snap, Assert, SnapshotData::curcid, elog, ERROR, GetCurrentCommandId(), IsInParallelMode(), and SnapshotData::regd_count.
Referenced by _SPI_execute_plan(), BeginCopyTo(), ExecCreateTableAs(), ExplainOnePlan(), fmgr_sql(), OldSnapshotThresholdActive(), PortalRunMulti(), and refresh_matview_datafill().
bool XactHasExportedSnapshots | ( | void | ) |
Definition at line 1552 of file snapmgr.c.
References NIL.
Referenced by OldSnapshotThresholdActive(), and PrepareTransaction().
bool XidInMVCCSnapshot | ( | TransactionId | xid, |
Snapshot | snapshot | ||
) |
Definition at line 2238 of file snapmgr.c.
References i, SnapshotData::suboverflowed, SubTransGetTopmostTransaction(), SnapshotData::subxcnt, SnapshotData::subxip, SnapshotData::takenDuringRecovery, TransactionIdEquals, TransactionIdFollowsOrEquals(), TransactionIdPrecedes(), SnapshotData::xcnt, SnapshotData::xip, SnapshotData::xmax, and SnapshotData::xmin.
Referenced by asyncQueueProcessPageEntries(), and HeapTupleSatisfiesMVCC().
|
static |
Definition at line 891 of file snapmgr.c.
References pairingheap_const_container, TransactionIdFollows(), TransactionIdPrecedes(), and SnapshotData::xmin.
|
static |
Definition at line 134 of file snapmgr.c.
Referenced by PushActiveSnapshot().
|
static |
Definition at line 104 of file snapmgr.c.
Referenced by GetNonHistoricCatalogSnapshot().
SnapshotData CatalogSnapshotData = {SNAPSHOT_MVCC} |
|
static |
Definition at line 102 of file snapmgr.c.
Referenced by GetTransactionSnapshot(), and SetTransactionSnapshot().
|
static |
Definition at line 149 of file snapmgr.c.
Referenced by AtEOXact_Snapshot(), check_transaction_deferrable(), check_transaction_read_only(), check_XactIsoLevel(), CreateReplicationSlot(), GetLatestSnapshot(), GetTransactionSnapshot(), ImportSnapshot(), SetTransactionSnapshot(), SnapBuildInitialSnapshot(), and SnapshotSetCommandId().
|
static |
Definition at line 105 of file snapmgr.c.
Referenced by GetCatalogSnapshot(), and GetTransactionSnapshot().
int old_snapshot_threshold |
Definition at line 78 of file snapmgr.c.
Referenced by heap_page_prune_opt(), MaintainOldSnapshotTimeMapping(), OldSnapshotThresholdActive(), should_attempt_truncation(), SnapMgrShmemSize(), SnapshotTooOldMagicForTest(), TestForOldSnapshot(), and TransactionIdLimitedForOldSnapshots().
|
static |
volatile OldSnapshotControlData* oldSnapshotControl |
Definition at line 80 of file snapmgr.c.
Referenced by GetOldSnapshotTimeMapping().
TransactionId RecentXmin = FirstNormalTransactionId |
Definition at line 113 of file snapmgr.c.
Referenced by ATRewriteTables(), bt_check_every_level(), GetSnapshotData(), GetSnapshotDataReuse(), GlobalVisTestFor(), GlobalVisTestShouldUpdate(), GlobalVisUpdateApply(), heap_hot_search_buffer(), heapam_relation_set_new_filenode(), index_getnext_tid(), refresh_by_heap_swap(), TransactionIdIsActive(), and TransactionIdIsInProgress().
|
static |
|
static |
Definition at line 103 of file snapmgr.c.
Referenced by GetLatestSnapshot().
|
static |
SnapshotData SnapshotAnyData = {SNAPSHOT_ANY} |
SnapshotData SnapshotSelfData = {SNAPSHOT_SELF} |
TransactionId TransactionXmin = FirstNormalTransactionId |
Definition at line 112 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 116 of file snapmgr.c.
Referenced by HistoricSnapshotGetTupleCids().