201 bool in_slot_creation,
210 "snapshot builder context",
283 elog(
ERROR,
"cannot free a copied snapshot");
285 if (
snap->active_count)
286 elog(
ERROR,
"cannot free an active snapshot");
297 return builder->
state;
336 snap->active_count++;
362 elog(
ERROR,
"cannot free a copied snapshot");
364 snap->active_count--;
365 if (
snap->active_count == 0)
472 elog(
ERROR,
"cannot build an initial slot snapshot when snapshots exist");
476 elog(
ERROR,
"cannot build an initial slot snapshot before reaching a consistent state");
479 elog(
ERROR,
"cannot build an initial slot snapshot, not all transactions are monitored anymore");
483 elog(
ERROR,
"cannot build an initial slot snapshot when MyProc->xmin already is valid");
501 elog(
ERROR,
"cannot build an initial slot snapshot as oldest safe xid %u follows snapshot's xmin %u",
531 errmsg(
"initial slot snapshot too large")));
562 elog(
ERROR,
"cannot export a snapshot from within a transaction");
565 elog(
ERROR,
"can only export one snapshot at a time");
585 (
errmsg_plural(
"exported logical decoding snapshot: \"%s\" with %u transaction ID",
586 "exported logical decoding snapshot: \"%s\" with %u transaction IDs",
626 elog(
ERROR,
"clearing exported snapshot in wrong transaction state");
733 elog(
ERROR,
"xl_heap_new_cid record without a valid CommandId");
794 elog(
DEBUG2,
"adding a new snapshot and invalidations to %u at %X/%08X",
830 if (ninvalidations > 0)
836 ninvalidations, msgs);
854 elog(
DEBUG1,
"increasing space for committed transactions to %u",
910 elog(
DEBUG3,
"purged committed transactions from %u to %u, xmin: %u, xmax: %u",
947 elog(
DEBUG3,
"purged catalog modifying transactions from %u to %u, xmin: %u, xmax: %u",
1012 elog(
DEBUG1,
"found subtransaction %u:%u with catalog changes",
1038 elog(
DEBUG2,
"found top level transaction %u, with catalog changes",
1047 elog(
DEBUG2,
"forced transaction %u to do timetravel due to one of its subtransactions",
1054 elog(
DEBUG2,
"forced transaction %u to do timetravel", xid);
1076 builder->
xmax = xmax;
1240 elog(
DEBUG3,
"xmin: %u, xmax: %u, oldest running: %u, oldest xmin: %u",
1276 else if (txn ==
NULL &&
1330 errmsg_internal(
"skipping snapshot at %X/%08X while building logical decoding snapshot, xmin horizon too low",
1369 errmsg(
"logical decoding found consistent point at %X/%08X",
1371 errdetail(
"There are no running transactions."));
1418 errmsg(
"logical decoding found initial starting point at %X/%08X",
1420 errdetail(
"Waiting for transactions (approximately %d) older than %u to end.",
1442 errmsg(
"logical decoding found initial consistent point at %X/%08X",
1444 errdetail(
"Waiting for transactions (approximately %d) older than %u to end.",
1466 errmsg(
"logical decoding found consistent point at %X/%08X",
1468 errdetail(
"There are no old transactions anymore."));
1495 for (off = 0; off < running->
xcnt; off++)
1529#define SnapBuildOnDiskConstantSize \
1530 offsetof(SnapBuildOnDisk, builder)
1531#define SnapBuildOnDiskNotChecksummedSize \
1532 offsetof(SnapBuildOnDisk, version)
1534#define SNAPBUILD_MAGIC 0x51A1E001
1535#define SNAPBUILD_VERSION 6
1592 sprintf(path,
"%s/%X-%X.snap",
1606 errmsg(
"could not stat file \"%s\": %m", path)));
1633 elog(
DEBUG1,
"serializing snapshot to %s", path);
1768 errmsg(
"could not rename file \"%s\" to \"%s\": %m",
1810 sprintf(path,
"%s/%X-%X.snap",
1823 errmsg(
"could not open file \"%s\": %m", path)));
1843 errmsg(
"snapbuild state file \"%s\" has wrong magic number: %u instead of %u",
1849 errmsg(
"snapbuild state file \"%s\" has unsupported version: %u instead of %u",
1882 errmsg(
"could not close file \"%s\": %m", path)));
1890 errmsg(
"checksum mismatch for snapbuild state file \"%s\": is %u, should be %u",
1891 path, checksum, ondisk->
checksum)));
1976 errmsg(
"logical decoding found consistent point at %X/%08X",
1978 errdetail(
"Logical decoding will begin using saved snapshot."));
2011 errmsg(
"could not read file \"%s\": %m", path)));
2016 errmsg(
"could not read file \"%s\": read %d of %zu",
2069 elog(
DEBUG1,
"only regular files expected: %s", path);
2085 (
errmsg(
"could not parse file name \"%s\"", path)));
2089 lsn = ((
uint64) hi) << 32 | lo;
2094 elog(
DEBUG1,
"removing snapbuild snapshot %s", path);
2105 errmsg(
"could not remove file \"%s\": %m",
2124 sprintf(path,
"%s/%X-%X.snap",
2133 errmsg(
"could not stat file \"%s\": %m", path)));
#define Assert(condition)
#define OidIsValid(objectId)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int int errdetail_internal(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
int int int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
#define ereport(elevel,...)
int CloseTransientFile(int fd)
void fsync_fname(const char *fname, bool isdir)
DIR * AllocateDir(const char *dirname)
struct dirent * ReadDir(DIR *dir, const char *dirname)
int OpenTransientFile(const char *fileName, int fileFlags)
#define repalloc_array(pointer, type, count)
#define palloc_array(type, count)
#define palloc0_array(type, count)
#define palloc0_object(type)
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
#define dlist_foreach(iter, lhead)
static uint32 dclist_count(const dclist_head *head)
#define dlist_container(type, membername, ptr)
void XactLockTableWait(TransactionId xid, Relation rel, const ItemPointerData *ctid, XLTW_Oper oper)
void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart_lsn)
void LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void * MemoryContextAlloc(MemoryContext context, Size size)
void * MemoryContextAllocZero(MemoryContext context, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define ERRCODE_DATA_CORRUPTED
#define COMP_CRC32C(crc, data, len)
#define EQ_CRC32C(c1, c2)
#define ERRCODE_T_R_SERIALIZATION_FAILURE
#define qsort(a, b, c, d)
static int fd(const char *x, int i)
TransactionId GetOldestSafeDecodingTransactionId(bool catalogOnly)
int GetMaxSnapshotXidCount(void)
void ReorderBufferXidSetCatalogChanges(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferAddNewCommandId(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, CommandId cid)
void ReorderBufferAddNewTupleCids(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, RelFileLocator locator, ItemPointerData tid, CommandId cmin, CommandId cmax, CommandId combocid)
void ReorderBufferSetBaseSnapshot(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Snapshot snap)
bool ReorderBufferXidHasCatalogChanges(ReorderBuffer *rb, TransactionId xid)
TransactionId ReorderBufferGetOldestXmin(ReorderBuffer *rb)
uint32 ReorderBufferGetInvalidations(ReorderBuffer *rb, TransactionId xid, SharedInvalidationMessage **msgs)
TransactionId * ReorderBufferGetCatalogChangesXacts(ReorderBuffer *rb)
void ReorderBufferAddDistributedInvalidations(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Size nmsgs, SharedInvalidationMessage *msgs)
bool ReorderBufferXidHasBaseSnapshot(ReorderBuffer *rb, TransactionId xid)
void ReorderBufferAddSnapshot(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Snapshot snap)
void ReorderBufferSetRestartPoint(ReorderBuffer *rb, XLogRecPtr ptr)
ReorderBufferTXN * ReorderBufferGetOldestTXN(ReorderBuffer *rb)
#define rbtxn_is_prepared(txn)
#define PG_LOGICAL_SNAPSHOTS_DIR
ResourceOwner CurrentResourceOwner
XLogRecPtr ReplicationSlotsComputeLogicalRestartLSN(void)
static void SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
void SnapBuildSnapDecRefcount(Snapshot snap)
bool SnapBuildRestoreSnapshot(SnapBuildOnDisk *ondisk, XLogRecPtr lsn, MemoryContext context, bool missing_ok)
#define SNAPBUILD_VERSION
bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr)
void SnapBuildResetExportedSnapshotState(void)
void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr)
static void SnapBuildSnapIncRefcount(Snapshot snap)
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
XLogRecPtr SnapBuildGetTwoPhaseAt(SnapBuild *builder)
SnapBuildState SnapBuildCurrentState(SnapBuild *builder)
SnapBuild * AllocateSnapshotBuilder(ReorderBuffer *reorder, TransactionId xmin_horizon, XLogRecPtr start_lsn, bool need_full_snapshot, bool in_slot_creation, XLogRecPtr two_phase_at)
#define SnapBuildOnDiskNotChecksummedSize
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *running, bool db_specific)
void FreeSnapshotBuilder(SnapBuild *builder)
bool SnapBuildSnapshotExists(XLogRecPtr lsn)
void CheckPointSnapBuild(void)
static void SnapBuildAddCommittedTxn(SnapBuild *builder, TransactionId xid)
static bool SnapBuildXidHasCatalogChanges(SnapBuild *builder, TransactionId xid, uint32 xinfo)
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder)
Snapshot SnapBuildInitialSnapshot(SnapBuild *builder)
const char * SnapBuildExportSnapshot(SnapBuild *builder)
static ResourceOwner SavedResourceOwnerDuringExport
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts, uint32 xinfo)
static void SnapBuildWaitSnapshot(xl_running_xacts *running, TransactionId cutoff)
static Snapshot SnapBuildBuildSnapshot(SnapBuild *builder)
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, xl_heap_new_cid *xlrec)
static void SnapBuildDistributeSnapshotAndInval(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid)
bool accessSharedCatalogsInDecoding
void SnapBuildClearExportedSnapshot(void)
static void SnapBuildFreeSnapshot(Snapshot snap)
static bool SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *running)
static bool ExportInProgress
static void SnapBuildPurgeOlderTxn(SnapBuild *builder)
#define SnapBuildOnDiskConstantSize
static void SnapBuildRestoreContents(int fd, void *dest, Size size, const char *path)
static bool SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
@ SNAPBUILD_BUILDING_SNAPSHOT
@ SNAPBUILD_FULL_SNAPSHOT
bool HistoricSnapshotActive(void)
bool HaveRegisteredOrActiveSnapshot(void)
char * ExportSnapshot(Snapshot snapshot)
void InvalidateCatalogSnapshot(void)
XLogRecPtr LogStandbySnapshot(Oid dbid)
XLogRecPtr restart_decoding_lsn
dclist_head catchange_txns
dlist_head toplevel_by_lsn
XLogRecPtr current_restart_decoding_lsn
XLogRecPtr start_decoding_at
TransactionId initial_xmin_horizon
struct SnapBuild::@127 catchange
bool building_full_snapshot
TransactionId next_phase_at
XLogRecPtr last_serialized_snapshot
bool includes_all_transactions
struct SnapBuild::@126 committed
uint64 snapXactCompletionCount
SnapshotType snapshot_type
TransactionId oldestRunningXid
TransactionId xids[FLEXIBLE_ARRAY_MEMBER]
static bool TransactionIdFollows(TransactionId id1, TransactionId id2)
#define InvalidTransactionId
static bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
static bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2)
#define NormalTransactionIdPrecedes(id1, id2)
#define NormalTransactionIdFollows(id1, id2)
#define TransactionIdIsValid(xid)
#define TransactionIdIsNormal(xid)
#define TransactionIdAdvance(dest)
static bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)
bool IsTransactionOrTransactionBlock(void)
bool IsTransactionState(void)
void StartTransactionCommand(void)
bool TransactionIdIsCurrentTransactionId(TransactionId xid)
void AbortCurrentTransaction(void)
#define XACT_REPEATABLE_READ
#define XACT_XINFO_HAS_INVALS
int xidComparator(const void *arg1, const void *arg2)
bool RecoveryInProgress(void)
XLogRecPtr GetRedoRecPtr(void)
#define XLogRecPtrIsValid(r)
#define LSN_FORMAT_ARGS(lsn)