PostgreSQL Source Code: src/include/replication/reorderbuffer.h File Reference (original) (raw)

Go to the source code of this file.

Data Structures
struct ReorderBufferChange
struct ReorderBufferTXN
struct ReorderBuffer
Macros
#define PG_LOGICAL_DIR "pg_logical"
#define PG_LOGICAL_MAPPINGS_DIR PG_LOGICAL_DIR "/mappings"
#define PG_LOGICAL_SNAPSHOTS_DIR PG_LOGICAL_DIR "/snapshots"
#define RBTXN_HAS_CATALOG_CHANGES 0x0001
#define RBTXN_IS_SUBXACT 0x0002
#define RBTXN_IS_SERIALIZED 0x0004
#define RBTXN_IS_SERIALIZED_CLEAR 0x0008
#define RBTXN_IS_STREAMED 0x0010
#define RBTXN_HAS_PARTIAL_CHANGE 0x0020
#define RBTXN_IS_PREPARED 0x0040
#define RBTXN_SKIPPED_PREPARE 0x0080
#define RBTXN_HAS_STREAMABLE_CHANGE 0x0100
#define RBTXN_SENT_PREPARE 0x0200
#define RBTXN_IS_COMMITTED 0x0400
#define RBTXN_IS_ABORTED 0x0800
#define RBTXN_PREPARE_STATUS_MASK (RBTXN_IS_PREPARED | RBTXN_SKIPPED_PREPARE RBTXN_SENT_PREPARE)
#define rbtxn_has_catalog_changes(txn)
#define rbtxn_is_known_subxact(txn)
#define rbtxn_is_serialized(txn)
#define rbtxn_is_serialized_clear(txn)
#define rbtxn_has_partial_change(txn)
#define rbtxn_has_streamable_change(txn)
#define rbtxn_is_streamed(txn)
#define rbtxn_is_prepared(txn)
#define rbtxn_sent_prepare(txn)
#define rbtxn_is_committed(txn)
#define rbtxn_is_aborted(txn)
#define rbtxn_skip_prepared(txn)
#define rbtxn_is_toptxn(txn)
#define rbtxn_is_subtxn(txn)
#define rbtxn_get_toptxn(txn)
Typedefs
typedef enum ReorderBufferChangeType ReorderBufferChangeType
typedef struct ReorderBufferChange ReorderBufferChange
typedef struct ReorderBufferTXN ReorderBufferTXN
typedef struct ReorderBuffer ReorderBuffer
typedef void(* ReorderBufferApplyChangeCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
typedef void(* ReorderBufferApplyTruncateCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
typedef void(* ReorderBufferBeginCB) (ReorderBuffer *rb, ReorderBufferTXN *txn)
typedef void(* ReorderBufferCommitCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
typedef void(* ReorderBufferMessageCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size sz, const char *message)
typedef void(* ReorderBufferBeginPrepareCB) (ReorderBuffer *rb, ReorderBufferTXN *txn)
typedef void(* ReorderBufferPrepareCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
typedef void(* ReorderBufferCommitPreparedCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
typedef void(* ReorderBufferRollbackPreparedCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_end_lsn, TimestampTz prepare_time)
typedef void(* ReorderBufferStreamStartCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr first_lsn)
typedef void(* ReorderBufferStreamStopCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr last_lsn)
typedef void(* ReorderBufferStreamAbortCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr abort_lsn)
typedef void(* ReorderBufferStreamPrepareCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
typedef void(* ReorderBufferStreamCommitCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
typedef void(* ReorderBufferStreamChangeCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
typedef void(* ReorderBufferStreamMessageCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size sz, const char *message)
typedef void(* ReorderBufferStreamTruncateCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
typedef void(* ReorderBufferUpdateProgressTxnCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr lsn)
Enumerations
enum DebugLogicalRepStreamingMode { DEBUG_LOGICAL_REP_STREAMING_BUFFERED, DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE }
enum ReorderBufferChangeType { REORDER_BUFFER_CHANGE_INSERT, REORDER_BUFFER_CHANGE_UPDATE, REORDER_BUFFER_CHANGE_DELETE, REORDER_BUFFER_CHANGE_MESSAGE, REORDER_BUFFER_CHANGE_INVALIDATION, REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT, REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID, REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT, REORDER_BUFFER_CHANGE_TRUNCATE }
Functions
ReorderBuffer * ReorderBufferAllocate (void)
void ReorderBufferFree (ReorderBuffer *rb)
HeapTuple ReorderBufferAllocTupleBuf (ReorderBuffer *rb, Size tuple_len)
void ReorderBufferFreeTupleBuf (HeapTuple tuple)
ReorderBufferChange * ReorderBufferAllocChange (ReorderBuffer *rb)
void ReorderBufferFreeChange (ReorderBuffer *rb, ReorderBufferChange *change, bool upd_mem)
Oid * ReorderBufferAllocRelids (ReorderBuffer *rb, int nrelids)
void ReorderBufferFreeRelids (ReorderBuffer *rb, Oid *relids)
void ReorderBufferQueueChange (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, ReorderBufferChange *change, bool toast_insert)
void ReorderBufferQueueMessage (ReorderBuffer *rb, TransactionId xid, Snapshot snap, XLogRecPtr lsn, bool transactional, const char *prefix, Size message_size, const char *message)
void ReorderBufferCommit (ReorderBuffer *rb, TransactionId xid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn, TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn)
void ReorderBufferFinishPrepared (ReorderBuffer *rb, TransactionId xid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn, XLogRecPtr two_phase_at, TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn, char *gid, bool is_commit)
void ReorderBufferAssignChild (ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr lsn)
void ReorderBufferCommitChild (ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn)
void ReorderBufferAbort (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, TimestampTz abort_time)
void ReorderBufferAbortOld (ReorderBuffer *rb, TransactionId oldestRunningXid)
void ReorderBufferForget (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferInvalidate (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferSetBaseSnapshot (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Snapshot snap)
void ReorderBufferAddSnapshot (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Snapshot snap)
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 ReorderBufferAddInvalidations (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Size nmsgs, SharedInvalidationMessage *msgs)
void ReorderBufferImmediateInvalidation (ReorderBuffer *rb, uint32 ninvalidations, SharedInvalidationMessage *invalidations)
void ReorderBufferProcessXid (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferXidSetCatalogChanges (ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
bool ReorderBufferXidHasCatalogChanges (ReorderBuffer *rb, TransactionId xid)
bool ReorderBufferXidHasBaseSnapshot (ReorderBuffer *rb, TransactionId xid)
bool ReorderBufferRememberPrepareInfo (ReorderBuffer *rb, TransactionId xid, XLogRecPtr prepare_lsn, XLogRecPtr end_lsn, TimestampTz prepare_time, RepOriginId origin_id, XLogRecPtr origin_lsn)
void ReorderBufferSkipPrepare (ReorderBuffer *rb, TransactionId xid)
void ReorderBufferPrepare (ReorderBuffer *rb, TransactionId xid, char *gid)
ReorderBufferTXN * ReorderBufferGetOldestTXN (ReorderBuffer *rb)
TransactionId ReorderBufferGetOldestXmin (ReorderBuffer *rb)
TransactionId * ReorderBufferGetCatalogChangesXacts (ReorderBuffer *rb)
void ReorderBufferSetRestartPoint (ReorderBuffer *rb, XLogRecPtr ptr)
uint32 ReorderBufferGetInvalidations (ReorderBuffer *rb, TransactionId xid, SharedInvalidationMessage **msgs)
void StartupReorderBuffer (void)

PG_LOGICAL_DIR

#define PG_LOGICAL_DIR "pg_logical"

PG_LOGICAL_MAPPINGS_DIR

PG_LOGICAL_SNAPSHOTS_DIR

rbtxn_get_toptxn

| #define rbtxn_get_toptxn | ( | | txn | ) | | -------------------------- | - | | --- | - |

Value:

( \

rbtxn_is_subtxn(txn) ? (txn)->toptxn : (txn) \

)

Definition at line 281 of file reorderbuffer.h.

RBTXN_HAS_CATALOG_CHANGES

#define RBTXN_HAS_CATALOG_CHANGES 0x0001

rbtxn_has_catalog_changes

| #define rbtxn_has_catalog_changes | ( | | txn | ) | | ------------------------------------ | - | | --- | - |

Value:

( \

)

#define RBTXN_HAS_CATALOG_CHANGES

Definition at line 183 of file reorderbuffer.h.

RBTXN_HAS_PARTIAL_CHANGE

#define RBTXN_HAS_PARTIAL_CHANGE 0x0020

rbtxn_has_partial_change

| #define rbtxn_has_partial_change | ( | | txn | ) | | ----------------------------------- | - | | --- | - |

Value:

( \

)

#define RBTXN_HAS_PARTIAL_CHANGE

Definition at line 207 of file reorderbuffer.h.

RBTXN_HAS_STREAMABLE_CHANGE

#define RBTXN_HAS_STREAMABLE_CHANGE 0x0100

rbtxn_has_streamable_change

| #define rbtxn_has_streamable_change | ( | | txn | ) | | -------------------------------------- | - | | --- | - |

Value:

( \

)

#define RBTXN_HAS_STREAMABLE_CHANGE

Definition at line 213 of file reorderbuffer.h.

RBTXN_IS_ABORTED

#define RBTXN_IS_ABORTED 0x0800

rbtxn_is_aborted

| #define rbtxn_is_aborted | ( | | txn | ) | | -------------------------- | - | | --- | - |

RBTXN_IS_COMMITTED

#define RBTXN_IS_COMMITTED 0x0400

rbtxn_is_committed

| #define rbtxn_is_committed | ( | | txn | ) | | ---------------------------- | - | | --- | - |

rbtxn_is_known_subxact

| #define rbtxn_is_known_subxact | ( | | txn | ) | | --------------------------------- | - | | --- | - |

RBTXN_IS_PREPARED

#define RBTXN_IS_PREPARED 0x0040

rbtxn_is_prepared

| #define rbtxn_is_prepared | ( | | txn | ) | | --------------------------- | - | | --- | - |

RBTXN_IS_SERIALIZED

#define RBTXN_IS_SERIALIZED 0x0004

rbtxn_is_serialized

| #define rbtxn_is_serialized | ( | | txn | ) | | ----------------------------- | - | | --- | - |

RBTXN_IS_SERIALIZED_CLEAR

#define RBTXN_IS_SERIALIZED_CLEAR 0x0008

rbtxn_is_serialized_clear

| #define rbtxn_is_serialized_clear | ( | | txn | ) | | ------------------------------------ | - | | --- | - |

Value:

( \

)

#define RBTXN_IS_SERIALIZED_CLEAR

Definition at line 201 of file reorderbuffer.h.

RBTXN_IS_STREAMED

#define RBTXN_IS_STREAMED 0x0010

rbtxn_is_streamed

| #define rbtxn_is_streamed | ( | | txn | ) | | --------------------------- | - | | --- | - |

rbtxn_is_subtxn

| #define rbtxn_is_subtxn | ( | | txn | ) | | ------------------------- | - | | --- | - |

RBTXN_IS_SUBXACT

#define RBTXN_IS_SUBXACT 0x0002

rbtxn_is_toptxn

| #define rbtxn_is_toptxn | ( | | txn | ) | | ------------------------- | - | | --- | - |

RBTXN_PREPARE_STATUS_MASK

RBTXN_SENT_PREPARE

#define RBTXN_SENT_PREPARE 0x0200

rbtxn_sent_prepare

| #define rbtxn_sent_prepare | ( | | txn | ) | | ---------------------------- | - | | --- | - |

rbtxn_skip_prepared

| #define rbtxn_skip_prepared | ( | | txn | ) | | ----------------------------- | - | | --- | - |

RBTXN_SKIPPED_PREPARE

#define RBTXN_SKIPPED_PREPARE 0x0080

ReorderBufferApplyChangeCB

ReorderBufferApplyTruncateCB

ReorderBufferBeginCB

ReorderBufferBeginPrepareCB

ReorderBufferChange

ReorderBufferChangeType

ReorderBufferCommitCB

ReorderBufferCommitPreparedCB

ReorderBufferMessageCB

ReorderBufferPrepareCB

ReorderBufferRollbackPreparedCB

ReorderBufferStreamAbortCB

ReorderBufferStreamChangeCB

ReorderBufferStreamCommitCB

ReorderBufferStreamMessageCB

ReorderBufferStreamPrepareCB

ReorderBufferStreamStartCB

ReorderBufferStreamStopCB

ReorderBufferStreamTruncateCB

ReorderBufferTXN

ReorderBufferUpdateProgressTxnCB

DebugLogicalRepStreamingMode

Enumerator
DEBUG_LOGICAL_REP_STREAMING_BUFFERED
DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE

Definition at line 31 of file reorderbuffer.h.

32{

DebugLogicalRepStreamingMode

@ DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE

@ DEBUG_LOGICAL_REP_STREAMING_BUFFERED

ReorderBufferChangeType

Enumerator
REORDER_BUFFER_CHANGE_INSERT
REORDER_BUFFER_CHANGE_UPDATE
REORDER_BUFFER_CHANGE_DELETE
REORDER_BUFFER_CHANGE_MESSAGE
REORDER_BUFFER_CHANGE_INVALIDATION
REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT
REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID
REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID
REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT
REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM
REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT
REORDER_BUFFER_CHANGE_TRUNCATE

Definition at line 50 of file reorderbuffer.h.

51{

@ REORDER_BUFFER_CHANGE_INVALIDATION

@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM

@ REORDER_BUFFER_CHANGE_INSERT

@ REORDER_BUFFER_CHANGE_MESSAGE

@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT

@ REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID

@ REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID

@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT

@ REORDER_BUFFER_CHANGE_TRUNCATE

@ REORDER_BUFFER_CHANGE_DELETE

@ REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT

@ REORDER_BUFFER_CHANGE_UPDATE

ReorderBufferAbort()

Definition at line 3040 of file reorderbuffer.c.

3042{

3044

3046 false);

3047

3048

3049 if (txn == NULL)

3050 return;

3051

3053

3054

3056 {

3058

3059

3060

3061

3062

3063

3064

3068 }

3069

3070

3072

3073

3075}

static void ReorderBufferCleanupTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)

void ReorderBufferImmediateInvalidation(ReorderBuffer *rb, uint32 ninvalidations, SharedInvalidationMessage *invalidations)

static ReorderBufferTXN * ReorderBufferTXNByXid(ReorderBuffer *rb, TransactionId xid, bool create, bool *is_new, XLogRecPtr lsn, bool create_as_top)

#define rbtxn_is_streamed(txn)

SharedInvalidationMessage * invalidations

union ReorderBufferTXN::@116 xact_time

ReorderBufferStreamAbortCB stream_abort

#define InvalidXLogRecPtr

References ReorderBufferTXN::abort_time, ReorderBufferTXN::final_lsn, ReorderBufferTXN::invalidations, InvalidXLogRecPtr, ReorderBufferTXN::ninvalidations, rbtxn_is_streamed, ReorderBufferCleanupTXN(), ReorderBufferImmediateInvalidation(), ReorderBufferTXNByXid(), ReorderBuffer::stream_abort, and ReorderBufferTXN::xact_time.

Referenced by DecodeAbort().

ReorderBufferAbortOld()

Definition at line 3085 of file reorderbuffer.c.

3086{

3088

3089

3090

3091

3092

3093

3094

3095

3097 {

3099

3101

3103 {

3104 elog(DEBUG2, "aborting old transaction %u", txn->xid);

3105

3106

3109

3110

3112 }

3113 else

3114 return;

3115 }

3116}

#define dlist_foreach_modify(iter, lhead)

#define dlist_container(type, membername, ptr)

dlist_head toplevel_by_lsn

bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)

References dlist_mutable_iter::cur, DEBUG2, dlist_container, dlist_foreach_modify, elog, InvalidXLogRecPtr, rbtxn_is_streamed, ReorderBufferCleanupTXN(), ReorderBuffer::stream_abort, ReorderBuffer::toplevel_by_lsn, TransactionIdPrecedes(), and ReorderBufferTXN::xid.

Referenced by standby_decode().

ReorderBufferAddInvalidations()

Definition at line 3438 of file reorderbuffer.c.

3441{

3445

3447

3449

3450

3451

3452

3453

3454

3456

3458

3459

3461 {

3467 }

3468 else

3469 {

3473

3477 }

3478

3486

3488

3490}

Assert(PointerIsAligned(start, uint64))

void * repalloc(void *pointer, Size size)

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

void ReorderBufferQueueChange(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, ReorderBufferChange *change, bool toast_insert)

ReorderBufferChange * ReorderBufferAllocChange(ReorderBuffer *rb)

#define rbtxn_get_toptxn(txn)

ReorderBufferChangeType action

union ReorderBufferChange::@110 data

struct ReorderBufferChange::@110::@115 inval

SharedInvalidationMessage * invalidations

References ReorderBufferChange::action, Assert(), ReorderBuffer::context, ReorderBufferChange::data, ReorderBufferChange::inval, ReorderBufferChange::invalidations, ReorderBufferTXN::invalidations, MemoryContextSwitchTo(), ReorderBufferChange::ninvalidations, ReorderBufferTXN::ninvalidations, palloc(), rbtxn_get_toptxn, REORDER_BUFFER_CHANGE_INVALIDATION, ReorderBufferAllocChange(), ReorderBufferQueueChange(), ReorderBufferTXNByXid(), and repalloc().

Referenced by SnapBuildDistributeSnapshotAndInval(), and xact_decode().

ReorderBufferAddNewCommandId()

ReorderBufferAddNewTupleCids()

Definition at line 3401 of file reorderbuffer.c.

3405{

3408

3410

3416 change->lsn = lsn;

3417 change->txn = txn;

3419

3422}

static void dlist_push_tail(dlist_head *head, dlist_node *node)

struct ReorderBufferTXN * txn

struct ReorderBufferChange::@110::@114 tuplecid

References ReorderBufferChange::action, ReorderBufferChange::cmax, ReorderBufferChange::cmin, ReorderBufferChange::combocid, ReorderBufferChange::data, dlist_push_tail(), ReorderBufferChange::locator, ReorderBufferChange::lsn, ReorderBufferChange::node, ReorderBufferTXN::ntuplecids, REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID, ReorderBufferAllocChange(), ReorderBufferTXNByXid(), ReorderBufferChange::tid, ReorderBufferChange::tuplecid, ReorderBufferTXN::tuplecids, and ReorderBufferChange::txn.

Referenced by SnapBuildProcessNewCid().

ReorderBufferAddSnapshot()

ReorderBufferAllocate()

Definition at line 312 of file reorderbuffer.c.

313{

317

319

320

322 "ReorderBuffer",

324

325 buffer =

327

328 memset(&hash_ctl, 0, sizeof(hash_ctl));

329

330 buffer->context = new_ctx;

331

333 "Change",

336

338 "TXN",

341

342

343

344

345

346

347

348

349

350

351

353 "Tuples",

357

361

362 buffer->by_txn = hash_create("ReorderBufferByXid", 1000, &hash_ctl,

364

367

368 buffer->outbuf = NULL;

370 buffer->size = 0;

371

372

374

383

385

389

390

391

392

393

394

396

397 return buffer;

398}

HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)

MemoryContext GenerationContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)

static void dlist_init(dlist_head *head)

static void dclist_init(dclist_head *head)

void * MemoryContextAlloc(MemoryContext context, Size size)

MemoryContext CurrentMemoryContext

#define AllocSetContextCreate

#define ALLOCSET_DEFAULT_SIZES

#define SLAB_DEFAULT_BLOCK_SIZE

pairingheap * pairingheap_allocate(pairingheap_comparator compare, void *arg)

static int ReorderBufferTXNSizeCompare(const pairingheap_node *a, const pairingheap_node *b, void *arg)

struct ReorderBufferTXNByIdEnt ReorderBufferTXNByIdEnt

static void ReorderBufferCleanupSerializedTXNs(const char *slotname)

MemoryContext SlabContextCreate(MemoryContext parent, const char *name, Size blockSize, Size chunkSize)

ReplicationSlot * MyReplicationSlot

dlist_head txns_by_base_snapshot_lsn

dclist_head catchange_txns

MemoryContext change_context

ReorderBufferTXN * by_txn_last_txn

TransactionId by_txn_last_xid

MemoryContext tup_context

MemoryContext txn_context

XLogRecPtr current_restart_decoding_lsn

ReplicationSlotPersistentData data

#define InvalidTransactionId

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), ReorderBuffer::by_txn, ReorderBuffer::by_txn_last_txn, ReorderBuffer::by_txn_last_xid, ReorderBuffer::catchange_txns, ReorderBuffer::change_context, ReorderBuffer::context, ReorderBuffer::current_restart_decoding_lsn, CurrentMemoryContext, ReplicationSlot::data, dclist_init(), dlist_init(), HASHCTL::entrysize, GenerationContextCreate(), HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASHCTL::hcxt, InvalidTransactionId, InvalidXLogRecPtr, HASHCTL::keysize, MemoryContextAlloc(), MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, ReorderBuffer::outbuf, ReorderBuffer::outbufsize, pairingheap_allocate(), ReorderBufferCleanupSerializedTXNs(), ReorderBufferTXNSizeCompare(), ReorderBuffer::size, SLAB_DEFAULT_BLOCK_SIZE, SlabContextCreate(), ReorderBuffer::spillBytes, ReorderBuffer::spillCount, ReorderBuffer::spillTxns, ReorderBuffer::streamBytes, ReorderBuffer::streamCount, ReorderBuffer::streamTxns, ReorderBuffer::toplevel_by_lsn, ReorderBuffer::totalBytes, ReorderBuffer::totalTxns, ReorderBuffer::tup_context, ReorderBuffer::txn_context, ReorderBuffer::txn_heap, and ReorderBuffer::txns_by_base_snapshot_lsn.

Referenced by StartupDecodingContext().

ReorderBufferAllocChange()

Definition at line 488 of file reorderbuffer.c.

489{

491

494

496 return change;

497}

References ReorderBuffer::change_context, and MemoryContextAlloc().

Referenced by DecodeDelete(), DecodeInsert(), DecodeMultiInsert(), DecodeSpecConfirm(), DecodeTruncate(), DecodeUpdate(), ReorderBufferAddInvalidations(), ReorderBufferAddNewCommandId(), ReorderBufferAddNewTupleCids(), ReorderBufferAddSnapshot(), ReorderBufferQueueMessage(), and ReorderBufferRestoreChange().

ReorderBufferAllocRelids()

ReorderBufferAllocTupleBuf()

ReorderBufferAssignChild()

Definition at line 1080 of file reorderbuffer.c.

1082{

1085 bool new_top;

1086 bool new_sub;

1087

1090

1091 if (!new_sub)

1092 {

1094 {

1095

1096 return;

1097 }

1098 else

1099 {

1100

1101

1102

1103

1104

1106 }

1107 }

1108

1112

1113

1114 subtxn->toptxn = txn;

1115

1116

1119

1120

1122

1123

1125}

static void dlist_delete(dlist_node *node)

static void AssertTXNLsnOrder(ReorderBuffer *rb)

static void ReorderBufferTransferSnapToParent(ReorderBufferTXN *txn, ReorderBufferTXN *subtxn)

#define rbtxn_is_known_subxact(txn)

TransactionId toplevel_xid

struct ReorderBufferTXN * toptxn

References Assert(), AssertTXNLsnOrder(), dlist_delete(), dlist_push_tail(), ReorderBufferTXN::node, ReorderBufferTXN::nsubtxns, rbtxn_is_known_subxact, RBTXN_IS_SUBXACT, ReorderBufferTransferSnapToParent(), ReorderBufferTXNByXid(), ReorderBufferTXN::subtxns, ReorderBufferTXN::toplevel_xid, ReorderBufferTXN::toptxn, and ReorderBufferTXN::txn_flags.

Referenced by LogicalDecodingProcessRecord(), and ReorderBufferCommitChild().

ReorderBufferCommit()

Definition at line 2837 of file reorderbuffer.c.

2841{

2843

2845 false);

2846

2847

2848 if (txn == NULL)

2849 return;

2850

2852 origin_id, origin_lsn);

2853}

static void ReorderBufferReplay(ReorderBufferTXN *txn, ReorderBuffer *rb, TransactionId xid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn, TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn)

References InvalidXLogRecPtr, ReorderBufferReplay(), and ReorderBufferTXNByXid().

Referenced by DecodeCommit().

ReorderBufferCommitChild()

ReorderBufferFinishPrepared()

Definition at line 2954 of file reorderbuffer.c.

2959{

2963

2965

2966

2967 if (txn == NULL)

2968 return;

2969

2970

2971

2972

2973

2974 prepare_end_lsn = txn->end_lsn;

2976

2977

2979

2980

2981

2982

2983

2984

2985

2986

2987

2988 if ((txn->final_lsn < two_phase_at) && is_commit)

2989 {

2990

2991

2992

2993

2994

2998

2999

3000

3001

3002

3003

3004

3005

3008 }

3009

3015

3016 if (is_commit)

3018 else

3020

3021

3025}

char * pstrdup(const char *in)

static void ReorderBufferExecuteInvalidations(uint32 nmsgs, SharedInvalidationMessage *msgs)

#define RBTXN_PREPARE_STATUS_MASK

ReorderBufferCommitPreparedCB commit_prepared

ReorderBufferRollbackPreparedCB rollback_prepared

References Assert(), ReorderBuffer::commit_prepared, ReorderBufferTXN::commit_time, ReorderBufferTXN::end_lsn, ReorderBufferTXN::final_lsn, ReorderBufferTXN::gid, ReorderBufferTXN::invalidations, InvalidXLogRecPtr, ReorderBufferTXN::ninvalidations, ReorderBufferTXN::origin_id, ReorderBufferTXN::origin_lsn, ReorderBufferTXN::prepare_time, pstrdup(), RBTXN_IS_PREPARED, RBTXN_PREPARE_STATUS_MASK, RBTXN_SKIPPED_PREPARE, ReorderBufferCleanupTXN(), ReorderBufferExecuteInvalidations(), ReorderBufferReplay(), ReorderBufferTXNByXid(), ReorderBuffer::rollback_prepared, ReorderBufferTXN::txn_flags, and ReorderBufferTXN::xact_time.

Referenced by DecodeAbort(), and DecodeCommit().

ReorderBufferForget()

ReorderBufferFree()

ReorderBufferFreeChange()

Definition at line 503 of file reorderbuffer.c.

505{

506

507 if (upd_mem)

510

511

512 switch (change->action)

513 {

519 {

522 }

523

525 {

528 }

529 break;

537 break;

542 break;

545 {

548 }

549 break;

550

553 {

556 }

557 break;

562 break;

563 }

564

566}

void pfree(void *pointer)

void ReorderBufferFreeRelids(ReorderBuffer *rb, Oid *relids)

void ReorderBufferFreeTupleBuf(HeapTuple tuple)

static Size ReorderBufferChangeSize(ReorderBufferChange *change)

static void ReorderBufferFreeSnap(ReorderBuffer *rb, Snapshot snap)

static void ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb, ReorderBufferChange *change, ReorderBufferTXN *txn, bool addition, Size sz)

struct ReorderBufferChange::@110::@112 truncate

struct ReorderBufferChange::@110::@111 tp

struct ReorderBufferChange::@110::@113 msg

References ReorderBufferChange::action, ReorderBufferChange::data, ReorderBufferChange::inval, ReorderBufferChange::invalidations, ReorderBufferChange::message, ReorderBufferChange::msg, ReorderBufferChange::newtuple, ReorderBufferChange::oldtuple, pfree(), ReorderBufferChange::prefix, ReorderBufferChange::relids, REORDER_BUFFER_CHANGE_DELETE, REORDER_BUFFER_CHANGE_INSERT, REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID, REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT, REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID, REORDER_BUFFER_CHANGE_INVALIDATION, REORDER_BUFFER_CHANGE_MESSAGE, REORDER_BUFFER_CHANGE_TRUNCATE, REORDER_BUFFER_CHANGE_UPDATE, ReorderBufferChangeMemoryUpdate(), ReorderBufferChangeSize(), ReorderBufferFreeRelids(), ReorderBufferFreeSnap(), ReorderBufferFreeTupleBuf(), ReorderBufferChange::snapshot, ReorderBufferChange::tp, and ReorderBufferChange::truncate.

Referenced by ReorderBufferCleanupTXN(), ReorderBufferIterTXNFinish(), ReorderBufferIterTXNNext(), ReorderBufferProcessTXN(), ReorderBufferQueueChange(), ReorderBufferResetTXN(), ReorderBufferRestoreChanges(), ReorderBufferSerializeTXN(), ReorderBufferToastReset(), and ReorderBufferTruncateTXN().

ReorderBufferFreeRelids()

ReorderBufferFreeTupleBuf()

void ReorderBufferFreeTupleBuf ( HeapTuple tuple )

ReorderBufferGetCatalogChangesXacts()

Definition at line 3547 of file reorderbuffer.c.

3548{

3551 size_t xcnt = 0;

3552

3553

3555 return NULL;

3556

3557

3561 {

3563 catchange_node,

3564 iter.cur);

3565

3567

3568 xids[xcnt++] = txn->xid;

3569 }

3570

3572

3574 return xids;

3575}

#define dclist_container(type, membername, ptr)

static uint32 dclist_count(const dclist_head *head)

#define dclist_foreach(iter, lhead)

#define qsort(a, b, c, d)

#define rbtxn_has_catalog_changes(txn)

int xidComparator(const void *arg1, const void *arg2)

References Assert(), ReorderBuffer::catchange_txns, dlist_iter::cur, dclist_container, dclist_count(), dclist_foreach, palloc(), qsort, rbtxn_has_catalog_changes, ReorderBufferTXN::xid, and xidComparator().

Referenced by SnapBuildSerialize().

ReorderBufferGetInvalidations()

ReorderBufferGetOldestTXN()

ReorderBufferGetOldestXmin()

ReorderBufferImmediateInvalidation()

ReorderBufferInvalidate()

ReorderBufferPrepare()

Definition at line 2913 of file reorderbuffer.c.

2915{

2917

2919 false);

2920

2921

2922 if (txn == NULL)

2923 return;

2924

2925

2926

2927

2928

2929

2932

2934

2937

2938

2939

2940

2941

2942

2944 {

2947 }

2948}

#define rbtxn_sent_prepare(txn)

ReorderBufferPrepareCB prepare

References Assert(), ReorderBufferTXN::end_lsn, ReorderBufferTXN::final_lsn, ReorderBufferTXN::gid, InvalidXLogRecPtr, ReorderBufferTXN::origin_id, ReorderBufferTXN::origin_lsn, ReorderBuffer::prepare, ReorderBufferTXN::prepare_time, pstrdup(), RBTXN_IS_PREPARED, RBTXN_PREPARE_STATUS_MASK, RBTXN_SENT_PREPARE, rbtxn_sent_prepare, ReorderBufferReplay(), ReorderBufferTXNByXid(), ReorderBufferTXN::txn_flags, and ReorderBufferTXN::xact_time.

Referenced by DecodePrepare().

ReorderBufferProcessXid()

ReorderBufferQueueChange()

Definition at line 791 of file reorderbuffer.c.

793{

795

797

798

799

800

801

802

804 {

805

806

807

808

810 return;

811 }

812

813

814

815

816

817

824 {

826

828 }

829

830 change->lsn = lsn;

831 change->txn = txn;

832

837

838

841

842

844

845

847}

void ReorderBufferFreeChange(ReorderBuffer *rb, ReorderBufferChange *change, bool upd_mem)

static void ReorderBufferProcessPartialChange(ReorderBuffer *rb, ReorderBufferTXN *txn, ReorderBufferChange *change, bool toast_insert)

static void ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)

#define rbtxn_is_aborted(txn)

References ReorderBufferChange::action, Assert(), ReorderBufferTXN::changes, dlist_push_tail(), InvalidXLogRecPtr, ReorderBufferChange::lsn, ReorderBufferTXN::nentries, ReorderBufferTXN::nentries_mem, ReorderBufferChange::node, rbtxn_get_toptxn, RBTXN_HAS_STREAMABLE_CHANGE, rbtxn_is_aborted, REORDER_BUFFER_CHANGE_DELETE, REORDER_BUFFER_CHANGE_INSERT, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT, REORDER_BUFFER_CHANGE_MESSAGE, REORDER_BUFFER_CHANGE_TRUNCATE, REORDER_BUFFER_CHANGE_UPDATE, ReorderBufferChangeMemoryUpdate(), ReorderBufferChangeSize(), ReorderBufferCheckMemoryLimit(), ReorderBufferFreeChange(), ReorderBufferProcessPartialChange(), ReorderBufferTXNByXid(), ReorderBufferChange::txn, and ReorderBufferTXN::txn_flags.

Referenced by DecodeDelete(), DecodeInsert(), DecodeMultiInsert(), DecodeSpecConfirm(), DecodeTruncate(), DecodeUpdate(), ReorderBufferAddInvalidations(), ReorderBufferAddNewCommandId(), ReorderBufferAddSnapshot(), and ReorderBufferQueueMessage().

ReorderBufferQueueMessage()

Definition at line 854 of file reorderbuffer.c.

858{

859 if (transactional)

860 {

863

865

866

867

868

869

870

872

874

880 memcpy(change->data.msg.message, message, message_size);

881

883

885 }

886 else

887 {

889 volatile Snapshot snapshot_now = snap;

890

891

892 Assert(snapshot_now);

893

896

897

900 {

901 rb->message(rb, txn, lsn, false, prefix, message_size, message);

902

904 }

906 {

909 }

911 }

912}

void TeardownHistoricSnapshot(bool is_error)

void SetupHistoricSnapshot(Snapshot historic_snapshot, HTAB *tuplecids)

ReorderBufferMessageCB message

References ReorderBufferChange::action, Assert(), ReorderBuffer::context, ReorderBufferChange::data, InvalidTransactionId, MemoryContextSwitchTo(), ReorderBufferChange::message, ReorderBuffer::message, ReorderBufferChange::message_size, ReorderBufferChange::msg, palloc(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, ReorderBufferChange::prefix, pstrdup(), REORDER_BUFFER_CHANGE_MESSAGE, ReorderBufferAllocChange(), ReorderBufferQueueChange(), ReorderBufferTXNByXid(), SetupHistoricSnapshot(), and TeardownHistoricSnapshot().

Referenced by logicalmsg_decode().

ReorderBufferRememberPrepareInfo()

Definition at line 2860 of file reorderbuffer.c.

2864{

2866

2868

2869

2870 if (txn == NULL)

2871 return false;

2872

2873

2874

2875

2876

2882

2883

2886

2887 return true;

2888}

References Assert(), ReorderBufferTXN::end_lsn, ReorderBufferTXN::final_lsn, InvalidXLogRecPtr, ReorderBufferTXN::origin_id, ReorderBufferTXN::origin_lsn, ReorderBufferTXN::prepare_time, RBTXN_IS_PREPARED, RBTXN_PREPARE_STATUS_MASK, ReorderBufferTXNByXid(), ReorderBufferTXN::txn_flags, and ReorderBufferTXN::xact_time.

Referenced by DecodePrepare().

ReorderBufferSetBaseSnapshot()

Definition at line 3271 of file reorderbuffer.c.

3273{

3275 bool is_new;

3276

3277 Assert(snap != NULL);

3278

3279

3280

3281

3282

3288

3292

3294}

XLogRecPtr base_snapshot_lsn

dlist_node base_snapshot_node

References Assert(), AssertTXNLsnOrder(), ReorderBufferTXN::base_snapshot, ReorderBufferTXN::base_snapshot_lsn, ReorderBufferTXN::base_snapshot_node, dlist_push_tail(), InvalidXLogRecPtr, rbtxn_is_known_subxact, ReorderBufferTXNByXid(), ReorderBufferTXN::toplevel_xid, and ReorderBuffer::txns_by_base_snapshot_lsn.

Referenced by SnapBuildCommitTxn(), and SnapBuildProcessChange().

ReorderBufferSetRestartPoint()

ReorderBufferSkipPrepare()

ReorderBufferXidHasBaseSnapshot()

ReorderBufferXidHasCatalogChanges()

ReorderBufferXidSetCatalogChanges()

Definition at line 3509 of file reorderbuffer.c.

3511{

3513

3515

3517 {

3520 }

3521

3522

3523

3524

3525

3526

3527

3529 {

3531

3533 {

3536 }

3537 }

3538}

static void dclist_push_tail(dclist_head *head, dlist_node *node)

#define rbtxn_is_subtxn(txn)

dlist_node catchange_node

References ReorderBufferTXN::catchange_node, ReorderBuffer::catchange_txns, dclist_push_tail(), rbtxn_get_toptxn, RBTXN_HAS_CATALOG_CHANGES, rbtxn_has_catalog_changes, rbtxn_is_subtxn, ReorderBufferTXNByXid(), and ReorderBufferTXN::txn_flags.

Referenced by SnapBuildProcessNewCid(), and xact_decode().

StartupReorderBuffer()

void StartupReorderBuffer ( void )

Definition at line 4777 of file reorderbuffer.c.

4778{

4779 DIR *logical_dir;

4780 struct dirent *logical_de;

4781

4784 {

4785 if (strcmp(logical_de->d_name, ".") == 0 ||

4786 strcmp(logical_de->d_name, "..") == 0)

4787 continue;

4788

4789

4791 continue;

4792

4793

4794

4795

4796

4798 }

4800}

DIR * AllocateDir(const char *dirname)

struct dirent * ReadDir(DIR *dir, const char *dirname)

bool ReplicationSlotValidateName(const char *name, int elevel)

References AllocateDir(), dirent::d_name, DEBUG2, FreeDir(), PG_REPLSLOT_DIR, ReadDir(), ReorderBufferCleanupSerializedTXNs(), and ReplicationSlotValidateName().

Referenced by StartupXLOG().

debug_logical_replication_streaming

logical_decoding_work_mem