PostgreSQL Source Code  git master
reorderbuffer.h File Reference
#include "access/htup_details.h"
#include "lib/ilist.h"
#include "storage/sinval.h"
#include "utils/hsearch.h"
#include "utils/relcache.h"
#include "utils/snapshot.h"
#include "utils/timestamp.h"
Include dependency graph for reorderbuffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ReorderBufferTupleBuf
 
struct  ReorderBufferChange
 
struct  ReorderBufferTXN
 
struct  ReorderBuffer
 

Macros

#define ReorderBufferTupleBufData(p)    ((HeapTupleHeader) MAXALIGN(((char *) p) + sizeof(ReorderBufferTupleBuf)))
 
#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_PREPARE   0x0040
 
#define RBTXN_SKIPPED_PREPARE   0x0080
 
#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_is_streamed(txn)
 
#define rbtxn_prepared(txn)
 
#define rbtxn_skip_prepared(txn)
 

Typedefs

typedef struct ReorderBufferTupleBuf ReorderBufferTupleBuf
 
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)
 

Enumerations

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

ReorderBufferReorderBufferAllocate (void)
 
void ReorderBufferFree (ReorderBuffer *)
 
ReorderBufferTupleBufReorderBufferGetTupleBuf (ReorderBuffer *, Size tuple_len)
 
void ReorderBufferReturnTupleBuf (ReorderBuffer *, ReorderBufferTupleBuf *tuple)
 
ReorderBufferChangeReorderBufferGetChange (ReorderBuffer *)
 
void ReorderBufferReturnChange (ReorderBuffer *, ReorderBufferChange *, bool)
 
OidReorderBufferGetRelids (ReorderBuffer *, int nrelids)
 
void ReorderBufferReturnRelids (ReorderBuffer *, Oid *relids)
 
void ReorderBufferQueueChange (ReorderBuffer *, TransactionId, XLogRecPtr lsn, ReorderBufferChange *, bool toast_insert)
 
void ReorderBufferQueueMessage (ReorderBuffer *, TransactionId, Snapshot snapshot, XLogRecPtr lsn, bool transactional, const char *prefix, Size message_size, const char *message)
 
void ReorderBufferCommit (ReorderBuffer *, TransactionId, 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 *, TransactionId, TransactionId, XLogRecPtr commit_lsn)
 
void ReorderBufferCommitChild (ReorderBuffer *, TransactionId, TransactionId, XLogRecPtr commit_lsn, XLogRecPtr end_lsn)
 
void ReorderBufferAbort (ReorderBuffer *, TransactionId, XLogRecPtr lsn)
 
void ReorderBufferAbortOld (ReorderBuffer *, TransactionId xid)
 
void ReorderBufferForget (ReorderBuffer *, TransactionId, XLogRecPtr lsn)
 
void ReorderBufferInvalidate (ReorderBuffer *, TransactionId, XLogRecPtr lsn)
 
void ReorderBufferSetBaseSnapshot (ReorderBuffer *, TransactionId, XLogRecPtr lsn, struct SnapshotData *snap)
 
void ReorderBufferAddSnapshot (ReorderBuffer *, TransactionId, XLogRecPtr lsn, struct SnapshotData *snap)
 
void ReorderBufferAddNewCommandId (ReorderBuffer *, TransactionId, XLogRecPtr lsn, CommandId cid)
 
void ReorderBufferAddNewTupleCids (ReorderBuffer *, TransactionId, XLogRecPtr lsn, RelFileNode node, ItemPointerData pt, CommandId cmin, CommandId cmax, CommandId combocid)
 
void ReorderBufferAddInvalidations (ReorderBuffer *, TransactionId, XLogRecPtr lsn, Size nmsgs, SharedInvalidationMessage *msgs)
 
void ReorderBufferImmediateInvalidation (ReorderBuffer *, uint32 ninvalidations, SharedInvalidationMessage *invalidations)
 
void ReorderBufferProcessXid (ReorderBuffer *, TransactionId xid, XLogRecPtr lsn)
 
void ReorderBufferXidSetCatalogChanges (ReorderBuffer *, TransactionId xid, XLogRecPtr lsn)
 
bool ReorderBufferXidHasCatalogChanges (ReorderBuffer *, TransactionId xid)
 
bool ReorderBufferXidHasBaseSnapshot (ReorderBuffer *, 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)
 
ReorderBufferTXNReorderBufferGetOldestTXN (ReorderBuffer *)
 
TransactionId ReorderBufferGetOldestXmin (ReorderBuffer *rb)
 
void ReorderBufferSetRestartPoint (ReorderBuffer *, XLogRecPtr ptr)
 
void StartupReorderBuffer (void)
 

Variables

PGDLLIMPORT int logical_decoding_work_mem
 

Macro Definition Documentation

◆ RBTXN_HAS_CATALOG_CHANGES

#define RBTXN_HAS_CATALOG_CHANGES   0x0001

Definition at line 171 of file reorderbuffer.h.

◆ rbtxn_has_catalog_changes

#define rbtxn_has_catalog_changes (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_HAS_CATALOG_CHANGES) != 0 \
)
#define RBTXN_HAS_CATALOG_CHANGES

Definition at line 181 of file reorderbuffer.h.

◆ RBTXN_HAS_PARTIAL_CHANGE

#define RBTXN_HAS_PARTIAL_CHANGE   0x0020

Definition at line 176 of file reorderbuffer.h.

◆ rbtxn_has_partial_change

#define rbtxn_has_partial_change (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_HAS_PARTIAL_CHANGE) != 0 \
)
#define RBTXN_HAS_PARTIAL_CHANGE

Definition at line 205 of file reorderbuffer.h.

◆ rbtxn_is_known_subxact

#define rbtxn_is_known_subxact (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_IS_SUBXACT) != 0 \
)
#define RBTXN_IS_SUBXACT

Definition at line 187 of file reorderbuffer.h.

◆ RBTXN_IS_SERIALIZED

#define RBTXN_IS_SERIALIZED   0x0004

Definition at line 173 of file reorderbuffer.h.

◆ rbtxn_is_serialized

#define rbtxn_is_serialized (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_IS_SERIALIZED) != 0 \
)
#define RBTXN_IS_SERIALIZED

Definition at line 193 of file reorderbuffer.h.

◆ RBTXN_IS_SERIALIZED_CLEAR

#define RBTXN_IS_SERIALIZED_CLEAR   0x0008

Definition at line 174 of file reorderbuffer.h.

◆ rbtxn_is_serialized_clear

#define rbtxn_is_serialized_clear (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_IS_SERIALIZED_CLEAR) != 0 \
)
#define RBTXN_IS_SERIALIZED_CLEAR

Definition at line 199 of file reorderbuffer.h.

◆ RBTXN_IS_STREAMED

#define RBTXN_IS_STREAMED   0x0010

Definition at line 175 of file reorderbuffer.h.

◆ rbtxn_is_streamed

#define rbtxn_is_streamed (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_IS_STREAMED) != 0 \
)
#define RBTXN_IS_STREAMED

Definition at line 219 of file reorderbuffer.h.

◆ RBTXN_IS_SUBXACT

#define RBTXN_IS_SUBXACT   0x0002

Definition at line 172 of file reorderbuffer.h.

◆ RBTXN_PREPARE

#define RBTXN_PREPARE   0x0040

Definition at line 177 of file reorderbuffer.h.

◆ rbtxn_prepared

#define rbtxn_prepared (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_PREPARE) != 0 \
)
#define RBTXN_PREPARE

Definition at line 225 of file reorderbuffer.h.

◆ rbtxn_skip_prepared

#define rbtxn_skip_prepared (   txn)
Value:
( \
((txn)->txn_flags & RBTXN_SKIPPED_PREPARE) != 0 \
)
#define RBTXN_SKIPPED_PREPARE

Definition at line 231 of file reorderbuffer.h.

◆ RBTXN_SKIPPED_PREPARE

#define RBTXN_SKIPPED_PREPARE   0x0080

Definition at line 178 of file reorderbuffer.h.

◆ ReorderBufferTupleBufData

#define ReorderBufferTupleBufData (   p)     ((HeapTupleHeader) MAXALIGN(((char *) p) + sizeof(ReorderBufferTupleBuf)))

Definition at line 38 of file reorderbuffer.h.

Typedef Documentation

◆ ReorderBuffer

typedef struct ReorderBuffer ReorderBuffer

Definition at line 20 of file reorderbuffer.h.

◆ ReorderBufferApplyChangeCB

typedef void(* ReorderBufferApplyChangeCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)

Definition at line 404 of file reorderbuffer.h.

◆ ReorderBufferApplyTruncateCB

typedef void(* ReorderBufferApplyTruncateCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)

Definition at line 410 of file reorderbuffer.h.

◆ ReorderBufferBeginCB

typedef void(* ReorderBufferBeginCB) (ReorderBuffer *rb, ReorderBufferTXN *txn)

Definition at line 417 of file reorderbuffer.h.

◆ ReorderBufferBeginPrepareCB

typedef void(* ReorderBufferBeginPrepareCB) (ReorderBuffer *rb, ReorderBufferTXN *txn)

Definition at line 434 of file reorderbuffer.h.

◆ ReorderBufferChange

◆ ReorderBufferChangeType

◆ ReorderBufferCommitCB

typedef void(* ReorderBufferCommitCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)

Definition at line 421 of file reorderbuffer.h.

◆ ReorderBufferCommitPreparedCB

typedef void(* ReorderBufferCommitPreparedCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)

Definition at line 443 of file reorderbuffer.h.

◆ ReorderBufferMessageCB

typedef void(* ReorderBufferMessageCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size sz, const char *message)

Definition at line 426 of file reorderbuffer.h.

◆ ReorderBufferPrepareCB

typedef void(* ReorderBufferPrepareCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)

Definition at line 438 of file reorderbuffer.h.

◆ ReorderBufferRollbackPreparedCB

typedef void(* ReorderBufferRollbackPreparedCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_end_lsn, TimestampTz prepare_time)

Definition at line 448 of file reorderbuffer.h.

◆ ReorderBufferStreamAbortCB

typedef void(* ReorderBufferStreamAbortCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr abort_lsn)

Definition at line 466 of file reorderbuffer.h.

◆ ReorderBufferStreamChangeCB

typedef void(* ReorderBufferStreamChangeCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)

Definition at line 484 of file reorderbuffer.h.

◆ ReorderBufferStreamCommitCB

typedef void(* ReorderBufferStreamCommitCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)

Definition at line 478 of file reorderbuffer.h.

◆ ReorderBufferStreamMessageCB

typedef void(* ReorderBufferStreamMessageCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size sz, const char *message)

Definition at line 491 of file reorderbuffer.h.

◆ ReorderBufferStreamPrepareCB

typedef void(* ReorderBufferStreamPrepareCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)

Definition at line 472 of file reorderbuffer.h.

◆ ReorderBufferStreamStartCB

typedef void(* ReorderBufferStreamStartCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr first_lsn)

Definition at line 454 of file reorderbuffer.h.

◆ ReorderBufferStreamStopCB

typedef void(* ReorderBufferStreamStopCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr last_lsn)

Definition at line 460 of file reorderbuffer.h.

◆ ReorderBufferStreamTruncateCB

typedef void(* ReorderBufferStreamTruncateCB) (ReorderBuffer *rb, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)

Definition at line 500 of file reorderbuffer.h.

◆ ReorderBufferTupleBuf

◆ ReorderBufferTXN

Enumeration Type Documentation

◆ 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 54 of file reorderbuffer.h.

55 {
ReorderBufferChangeType
Definition: reorderbuffer.h:55
@ REORDER_BUFFER_CHANGE_INVALIDATION
Definition: reorderbuffer.h:60
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM
Definition: reorderbuffer.h:65
@ REORDER_BUFFER_CHANGE_INSERT
Definition: reorderbuffer.h:56
@ REORDER_BUFFER_CHANGE_MESSAGE
Definition: reorderbuffer.h:59
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT
Definition: reorderbuffer.h:66
@ REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID
Definition: reorderbuffer.h:62
@ REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID
Definition: reorderbuffer.h:63
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT
Definition: reorderbuffer.h:64
@ REORDER_BUFFER_CHANGE_TRUNCATE
Definition: reorderbuffer.h:67
@ REORDER_BUFFER_CHANGE_DELETE
Definition: reorderbuffer.h:58
@ REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT
Definition: reorderbuffer.h:61
@ REORDER_BUFFER_CHANGE_UPDATE
Definition: reorderbuffer.h:57

Function Documentation

◆ ReorderBufferAbort()

void ReorderBufferAbort ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn 
)

Definition at line 2829 of file reorderbuffer.c.

2830 {
2831  ReorderBufferTXN *txn;
2832 
2833  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
2834  false);
2835 
2836  /* unknown, nothing to remove */
2837  if (txn == NULL)
2838  return;
2839 
2840  /* For streamed transactions notify the remote node about the abort. */
2841  if (rbtxn_is_streamed(txn))
2842  {
2843  rb->stream_abort(rb, txn, lsn);
2844 
2845  /*
2846  * We might have decoded changes for this transaction that could load
2847  * the cache as per the current transaction's view (consider DDL's
2848  * happened in this transaction). We don't want the decoding of future
2849  * transactions to use those cache entries so execute invalidations.
2850  */
2851  if (txn->ninvalidations > 0)
2853  txn->invalidations);
2854  }
2855 
2856  /* cosmetic... */
2857  txn->final_lsn = lsn;
2858 
2859  /* remove potential on-disk data, and deallocate */
2860  ReorderBufferCleanupTXN(rb, txn);
2861 }
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
XLogRecPtr final_lsn
ReorderBufferStreamAbortCB stream_abort
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28

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

Referenced by DecodeAbort().

◆ ReorderBufferAbortOld()

void ReorderBufferAbortOld ( ReorderBuffer rb,
TransactionId  xid 
)

Definition at line 2871 of file reorderbuffer.c.

2872 {
2873  dlist_mutable_iter it;
2874 
2875  /*
2876  * Iterate through all (potential) toplevel TXNs and abort all that are
2877  * older than what possibly can be running. Once we've found the first
2878  * that is alive we stop, there might be some that acquired an xid earlier
2879  * but started writing later, but it's unlikely and they will be cleaned
2880  * up in a later call to this function.
2881  */
2883  {
2884  ReorderBufferTXN *txn;
2885 
2886  txn = dlist_container(ReorderBufferTXN, node, it.cur);
2887 
2888  if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
2889  {
2890  elog(DEBUG2, "aborting old transaction %u", txn->xid);
2891 
2892  /* remove potential on-disk data, and deallocate this tx */
2893  ReorderBufferCleanupTXN(rb, txn);
2894  }
2895  else
2896  return;
2897  }
2898 }
#define DEBUG2
Definition: elog.h:23
#define elog(elevel,...)
Definition: elog.h:218
#define dlist_foreach_modify(iter, lhead)
Definition: ilist.h:543
#define dlist_container(type, membername, ptr)
Definition: ilist.h:496
TransactionId xid
dlist_head toplevel_by_lsn
dlist_node * cur
Definition: ilist.h:180
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300

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

Referenced by standby_decode().

◆ ReorderBufferAddInvalidations()

void ReorderBufferAddInvalidations ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn,
Size  nmsgs,
SharedInvalidationMessage msgs 
)

Definition at line 3203 of file reorderbuffer.c.

3206 {
3207  ReorderBufferTXN *txn;
3208  MemoryContext oldcontext;
3209  ReorderBufferChange *change;
3210 
3211  txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
3212 
3213  oldcontext = MemoryContextSwitchTo(rb->context);
3214 
3215  /*
3216  * Collect all the invalidations under the top transaction so that we can
3217  * execute them all together. See comment atop this function
3218  */
3219  if (txn->toptxn)
3220  txn = txn->toptxn;
3221 
3222  Assert(nmsgs > 0);
3223 
3224  /* Accumulate invalidations. */
3225  if (txn->ninvalidations == 0)
3226  {
3227  txn->ninvalidations = nmsgs;
3229  palloc(sizeof(SharedInvalidationMessage) * nmsgs);
3230  memcpy(txn->invalidations, msgs,
3231  sizeof(SharedInvalidationMessage) * nmsgs);
3232  }
3233  else
3234  {
3237  (txn->ninvalidations + nmsgs));
3238 
3239  memcpy(txn->invalidations + txn->ninvalidations, msgs,
3240  nmsgs * sizeof(SharedInvalidationMessage));
3241  txn->ninvalidations += nmsgs;
3242  }
3243 
3244  change = ReorderBufferGetChange(rb);
3246  change->data.inval.ninvalidations = nmsgs;
3247  change->data.inval.invalidations = (SharedInvalidationMessage *)
3248  palloc(sizeof(SharedInvalidationMessage) * nmsgs);
3249  memcpy(change->data.inval.invalidations, msgs,
3250  sizeof(SharedInvalidationMessage) * nmsgs);
3251 
3252  ReorderBufferQueueChange(rb, xid, lsn, change, false);
3253 
3254  MemoryContextSwitchTo(oldcontext);
3255 }
Assert(fmt[strlen(fmt) - 1] !='\n')
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1188
void * palloc(Size size)
Definition: mcxt.c:1068
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
void ReorderBufferQueueChange(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, ReorderBufferChange *change, bool toast_insert)
ReorderBufferChange * ReorderBufferGetChange(ReorderBuffer *rb)
ReorderBufferChangeType action
Definition: reorderbuffer.h:85
union ReorderBufferChange::@105 data
struct ReorderBufferChange::@105::@110 inval
struct ReorderBufferTXN * toptxn
MemoryContext context

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

Referenced by xact_decode().

◆ ReorderBufferAddNewCommandId()

void ReorderBufferAddNewCommandId ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn,
CommandId  cid 
)

◆ ReorderBufferAddNewTupleCids()

void ReorderBufferAddNewTupleCids ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn,
RelFileNode  node,
ItemPointerData  pt,
CommandId  cmin,
CommandId  cmax,
CommandId  combocid 
)

Definition at line 3167 of file reorderbuffer.c.

3171 {
3173  ReorderBufferTXN *txn;
3174 
3175  txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
3176 
3177  change->data.tuplecid.node = node;
3178  change->data.tuplecid.tid = tid;
3179  change->data.tuplecid.cmin = cmin;
3180  change->data.tuplecid.cmax = cmax;
3181  change->data.tuplecid.combocid = combocid;
3182  change->lsn = lsn;
3183  change->txn = txn;
3185 
3186  dlist_push_tail(&txn->tuplecids, &change->node);
3187  txn->ntuplecids++;
3188 }
static void dlist_push_tail(dlist_head *head, dlist_node *node)
Definition: ilist.h:317
struct ReorderBufferTXN * txn
Definition: reorderbuffer.h:88
struct ReorderBufferChange::@105::@109 tuplecid
dlist_head tuplecids

References ReorderBufferChange::action, ReorderBufferChange::data, dlist_push_tail(), ReorderBufferChange::lsn, ReorderBufferChange::node, ReorderBufferTXN::ntuplecids, REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID, ReorderBufferGetChange(), ReorderBufferTXNByXid(), ReorderBufferChange::tuplecid, ReorderBufferTXN::tuplecids, and ReorderBufferChange::txn.

Referenced by SnapBuildProcessNewCid().

◆ ReorderBufferAddSnapshot()

void ReorderBufferAddSnapshot ( ReorderBuffer ,
TransactionId  ,
XLogRecPtr  lsn,
struct SnapshotData snap 
)

◆ ReorderBufferAllocate()

ReorderBuffer* ReorderBufferAllocate ( void  )

Definition at line 301 of file reorderbuffer.c.

302 {
303  ReorderBuffer *buffer;
304  HASHCTL hash_ctl;
305  MemoryContext new_ctx;
306 
307  Assert(MyReplicationSlot != NULL);
308 
309  /* allocate memory in own context, to have better accountability */
311  "ReorderBuffer",
313 
314  buffer =
315  (ReorderBuffer *) MemoryContextAlloc(new_ctx, sizeof(ReorderBuffer));
316 
317  memset(&hash_ctl, 0, sizeof(hash_ctl));
318 
319  buffer->context = new_ctx;
320 
321  buffer->change_context = SlabContextCreate(new_ctx,
322  "Change",
324  sizeof(ReorderBufferChange));
325 
326  buffer->txn_context = SlabContextCreate(new_ctx,
327  "TXN",
329  sizeof(ReorderBufferTXN));
330 
331  /*
332  * XXX the allocation sizes used below pre-date generation context's block
333  * growing code. These values should likely be benchmarked and set to
334  * more suitable values.
335  */
336  buffer->tup_context = GenerationContextCreate(new_ctx,
337  "Tuples",
341 
342  hash_ctl.keysize = sizeof(TransactionId);
343  hash_ctl.entrysize = sizeof(ReorderBufferTXNByIdEnt);
344  hash_ctl.hcxt = buffer->context;
345 
346  buffer->by_txn = hash_create("ReorderBufferByXid", 1000, &hash_ctl,
348 
350  buffer->by_txn_last_txn = NULL;
351 
352  buffer->outbuf = NULL;
353  buffer->outbufsize = 0;
354  buffer->size = 0;
355 
356  buffer->spillTxns = 0;
357  buffer->spillCount = 0;
358  buffer->spillBytes = 0;
359  buffer->streamTxns = 0;
360  buffer->streamCount = 0;
361  buffer->streamBytes = 0;
362  buffer->totalTxns = 0;
363  buffer->totalBytes = 0;
364 
366 
367  dlist_init(&buffer->toplevel_by_lsn);
369 
370  /*
371  * Ensure there's no stale data from prior uses of this slot, in case some
372  * prior exit avoided calling ReorderBufferFree. Failure to do this can
373  * produce duplicated txns, and it's very cheap if there's nothing there.
374  */
376 
377  return buffer;
378 }
#define NameStr(name)
Definition: c.h:681
uint32 TransactionId
Definition: c.h:587
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
Definition: dynahash.c:349
MemoryContext GenerationContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: generation.c:215
#define HASH_CONTEXT
Definition: hsearch.h:102
#define HASH_ELEM
Definition: hsearch.h:95
#define HASH_BLOBS
Definition: hsearch.h:97
static void dlist_init(dlist_head *head)
Definition: ilist.h:278
MemoryContext CurrentMemoryContext
Definition: mcxt.c:42
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:863
#define AllocSetContextCreate
Definition: memutils.h:173
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:197
#define SLAB_DEFAULT_BLOCK_SIZE
Definition: memutils.h:226
#define SLAB_LARGE_BLOCK_SIZE
Definition: memutils.h:227
struct ReorderBufferTXNByIdEnt ReorderBufferTXNByIdEnt
static void ReorderBufferCleanupSerializedTXNs(const char *slotname)
MemoryContext SlabContextCreate(MemoryContext parent, const char *name, Size blockSize, Size chunkSize)
Definition: slab.c:175
ReplicationSlot * MyReplicationSlot
Definition: slot.c:97
Size keysize
Definition: hsearch.h:75
Size entrysize
Definition: hsearch.h:76
MemoryContext hcxt
Definition: hsearch.h:86
dlist_head txns_by_base_snapshot_lsn
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
Definition: slot.h:147
#define InvalidTransactionId
Definition: transam.h:31

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), ReorderBuffer::by_txn, ReorderBuffer::by_txn_last_txn, ReorderBuffer::by_txn_last_xid, ReorderBuffer::change_context, ReorderBuffer::context, ReorderBuffer::current_restart_decoding_lsn, CurrentMemoryContext, ReplicationSlot::data, 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, ReorderBufferCleanupSerializedTXNs(), ReorderBuffer::size, SLAB_DEFAULT_BLOCK_SIZE, SLAB_LARGE_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, and ReorderBuffer::txns_by_base_snapshot_lsn.

Referenced by StartupDecodingContext().

◆ ReorderBufferAssignChild()

void ReorderBufferAssignChild ( ReorderBuffer rb,
TransactionId  xid,
TransactionId  subxid,
XLogRecPtr  commit_lsn 
)

Definition at line 1021 of file reorderbuffer.c.

1023 {
1024  ReorderBufferTXN *txn;
1025  ReorderBufferTXN *subtxn;
1026  bool new_top;
1027  bool new_sub;
1028 
1029  txn = ReorderBufferTXNByXid(rb, xid, true, &new_top, lsn, true);
1030  subtxn = ReorderBufferTXNByXid(rb, subxid, true, &new_sub, lsn, false);
1031 
1032  if (!new_sub)
1033  {
1034  if (rbtxn_is_known_subxact(subtxn))
1035  {
1036  /* already associated, nothing to do */
1037  return;
1038  }
1039  else
1040  {
1041  /*
1042  * We already saw this transaction, but initially added it to the
1043  * list of top-level txns. Now that we know it's not top-level,
1044  * remove it from there.
1045  */
1046  dlist_delete(&subtxn->node);
1047  }
1048  }
1049 
1050  subtxn->txn_flags |= RBTXN_IS_SUBXACT;
1051  subtxn->toplevel_xid = xid;
1052  Assert(subtxn->nsubtxns == 0);
1053 
1054  /* set the reference to top-level transaction */
1055  subtxn->toptxn = txn;
1056 
1057  /* add to subtransaction list */
1058  dlist_push_tail(&txn->subtxns, &subtxn->node);
1059  txn->nsubtxns++;
1060 
1061  /* Possibly transfer the subtxn's snapshot to its top-level txn. */
1062  ReorderBufferTransferSnapToParent(txn, subtxn);
1063 
1064  /* Verify LSN-ordering invariant */
1065  AssertTXNLsnOrder(rb);
1066 }
static void dlist_delete(dlist_node *node)
Definition: ilist.h:358
static void AssertTXNLsnOrder(ReorderBuffer *rb)
static void ReorderBufferTransferSnapToParent(ReorderBufferTXN *txn, ReorderBufferTXN *subtxn)
#define rbtxn_is_known_subxact(txn)
TransactionId toplevel_xid
dlist_head subtxns

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()

void ReorderBufferCommit ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  commit_lsn,
XLogRecPtr  end_lsn,
TimestampTz  commit_time,
RepOriginId  origin_id,
XLogRecPtr  origin_lsn 
)

Definition at line 2638 of file reorderbuffer.c.

2642 {
2643  ReorderBufferTXN *txn;
2644 
2645  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
2646  false);
2647 
2648  /* unknown transaction, nothing to replay */
2649  if (txn == NULL)
2650  return;
2651 
2652  ReorderBufferReplay(txn, rb, xid, commit_lsn, end_lsn, commit_time,
2653  origin_id, origin_lsn);
2654 }
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()

void ReorderBufferCommitChild ( ReorderBuffer rb,
TransactionId  xid,
TransactionId  subxid,
XLogRecPtr  commit_lsn,
XLogRecPtr  end_lsn 
)

Definition at line 1141 of file reorderbuffer.c.

1144 {
1145  ReorderBufferTXN *subtxn;
1146 
1147  subtxn = ReorderBufferTXNByXid(rb, subxid, false, NULL,
1148  InvalidXLogRecPtr, false);
1149 
1150  /*
1151  * No need to do anything if that subtxn didn't contain any changes
1152  */
1153  if (!subtxn)
1154  return;
1155 
1156  subtxn->final_lsn = commit_lsn;
1157  subtxn->end_lsn = end_lsn;
1158 
1159  /*
1160  * Assign this subxact as a child of the toplevel xact (no-op if already
1161  * done.)
1162  */
1163  ReorderBufferAssignChild(rb, xid, subxid, InvalidXLogRecPtr);
1164 }
void ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr lsn)
XLogRecPtr end_lsn

References ReorderBufferTXN::end_lsn, ReorderBufferTXN::final_lsn, InvalidXLogRecPtr, ReorderBufferAssignChild(), and ReorderBufferTXNByXid().

Referenced by DecodeCommit(), and DecodePrepare().

◆ ReorderBufferFinishPrepared()

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 
)

Definition at line 2744 of file reorderbuffer.c.

2749 {
2750  ReorderBufferTXN *txn;
2751  XLogRecPtr prepare_end_lsn;
2752  TimestampTz prepare_time;
2753 
2754  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, commit_lsn, false);
2755 
2756  /* unknown transaction, nothing to do */
2757  if (txn == NULL)
2758  return;
2759 
2760  /*
2761  * By this time the txn has the prepare record information, remember it to
2762  * be later used for rollback.
2763  */
2764  prepare_end_lsn = txn->end_lsn;
2765  prepare_time = txn->xact_time.prepare_time;
2766 
2767  /* add the gid in the txn */
2768  txn->gid = pstrdup(gid);
2769 
2770  /*
2771  * It is possible that this transaction is not decoded at prepare time
2772  * either because by that time we didn't have a consistent snapshot, or
2773  * two_phase was not enabled, or it was decoded earlier but we have
2774  * restarted. We only need to send the prepare if it was not decoded
2775  * earlier. We don't need to decode the xact for aborts if it is not done
2776  * already.
2777  */
2778  if ((txn->final_lsn < two_phase_at) && is_commit)
2779  {
2780  txn->txn_flags |= RBTXN_PREPARE;
2781 
2782  /*
2783  * The prepare info must have been updated in txn even if we skip
2784  * prepare.
2785  */
2787 
2788  /*
2789  * By this time the txn has the prepare record information and it is
2790  * important to use that so that downstream gets the accurate
2791  * information. If instead, we have passed commit information here
2792  * then downstream can behave as it has already replayed commit
2793  * prepared after the restart.
2794  */
2795  ReorderBufferReplay(txn, rb, xid, txn->final_lsn, txn->end_lsn,
2796  txn->xact_time.prepare_time, txn->origin_id, txn->origin_lsn);
2797  }
2798 
2799  txn->final_lsn = commit_lsn;
2800  txn->end_lsn = end_lsn;
2801  txn->xact_time.commit_time = commit_time;
2802  txn->origin_id = origin_id;
2803  txn->origin_lsn = origin_lsn;
2804 
2805  if (is_commit)
2806  rb->commit_prepared(rb, txn, commit_lsn);
2807  else
2808  rb->rollback_prepared(rb, txn, prepare_end_lsn, prepare_time);
2809 
2810  /* cleanup: make sure there's no cache pollution */
2812  txn->invalidations);
2813  ReorderBufferCleanupTXN(rb, txn);
2814 }
int64 TimestampTz
Definition: timestamp.h:39
char * pstrdup(const char *in)
Definition: mcxt.c:1305
static void ReorderBufferExecuteInvalidations(uint32 nmsgs, SharedInvalidationMessage *msgs)
TimestampTz commit_time
RepOriginId origin_id
XLogRecPtr origin_lsn
TimestampTz prepare_time
union ReorderBufferTXN::@111 xact_time
ReorderBufferCommitPreparedCB commit_prepared
ReorderBufferRollbackPreparedCB rollback_prepared
uint64 XLogRecPtr
Definition: xlogdefs.h:21

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_PREPARE, ReorderBufferCleanupTXN(), ReorderBufferExecuteInvalidations(), ReorderBufferReplay(), ReorderBufferTXNByXid(), ReorderBuffer::rollback_prepared, ReorderBufferTXN::txn_flags, and ReorderBufferTXN::xact_time.

Referenced by DecodeAbort(), and DecodeCommit().

◆ ReorderBufferForget()

void ReorderBufferForget ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn 
)

Definition at line 2914 of file reorderbuffer.c.

2915 {
2916  ReorderBufferTXN *txn;
2917 
2918  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
2919  false);
2920 
2921  /* unknown, nothing to forget */
2922  if (txn == NULL)
2923  return;
2924 
2925  /* For streamed transactions notify the remote node about the abort. */
2926  if (rbtxn_is_streamed(txn))
2927  rb->stream_abort(rb, txn, lsn);
2928 
2929  /* cosmetic... */
2930  txn->final_lsn = lsn;
2931 
2932  /*
2933  * Process cache invalidation messages if there are any. Even if we're not
2934  * interested in the transaction's contents, it could have manipulated the
2935  * catalog and we need to update the caches according to that.
2936  */
2937  if (txn->base_snapshot != NULL && txn->ninvalidations > 0)
2939  txn->invalidations);
2940  else
2941  Assert(txn->ninvalidations == 0);
2942 
2943  /* remove potential on-disk data, and deallocate */
2944  ReorderBufferCleanupTXN(rb, txn);
2945 }
Snapshot base_snapshot

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

Referenced by DecodeCommit().

◆ ReorderBufferFree()

void ReorderBufferFree ( ReorderBuffer rb)

Definition at line 384 of file reorderbuffer.c.

385 {
386  MemoryContext context = rb->context;
387 
388  /*
389  * We free separately allocated data by entirely scrapping reorderbuffer's
390  * memory context.
391  */
392  MemoryContextDelete(context);
393 
394  /* Free disk space used by unconsumed reorder buffers */
396 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:218

References ReorderBuffer::context, ReplicationSlot::data, MemoryContextDelete(), MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, and ReorderBufferCleanupSerializedTXNs().

Referenced by FreeDecodingContext().

◆ ReorderBufferGetChange()

◆ ReorderBufferGetOldestTXN()

ReorderBufferTXN* ReorderBufferGetOldestTXN ( ReorderBuffer rb)

Definition at line 966 of file reorderbuffer.c.

967 {
968  ReorderBufferTXN *txn;
969 
970  AssertTXNLsnOrder(rb);
971 
973  return NULL;
974 
976 
979  return txn;
980 }
#define dlist_head_element(type, membername, lhead)
Definition: ilist.h:506
static bool dlist_is_empty(dlist_head *head)
Definition: ilist.h:289
XLogRecPtr first_lsn

References Assert(), AssertTXNLsnOrder(), dlist_head_element, dlist_is_empty(), ReorderBufferTXN::first_lsn, InvalidXLogRecPtr, rbtxn_is_known_subxact, and ReorderBuffer::toplevel_by_lsn.

Referenced by SnapBuildProcessRunningXacts().

◆ ReorderBufferGetOldestXmin()

TransactionId ReorderBufferGetOldestXmin ( ReorderBuffer rb)

Definition at line 994 of file reorderbuffer.c.

995 {
996  ReorderBufferTXN *txn;
997 
998  AssertTXNLsnOrder(rb);
999 
1001  return InvalidTransactionId;
1002 
1003  txn = dlist_head_element(ReorderBufferTXN, base_snapshot_node,
1005  return txn->base_snapshot->xmin;
1006 }
TransactionId xmin
Definition: snapshot.h:157

References AssertTXNLsnOrder(), ReorderBufferTXN::base_snapshot, dlist_head_element, dlist_is_empty(), InvalidTransactionId, ReorderBuffer::txns_by_base_snapshot_lsn, and SnapshotData::xmin.

Referenced by SnapBuildProcessRunningXacts().

◆ ReorderBufferGetRelids()

Oid* ReorderBufferGetRelids ( ReorderBuffer rb,
int  nrelids 
)

Definition at line 586 of file reorderbuffer.c.

587 {
588  Oid *relids;
589  Size alloc_len;
590 
591  alloc_len = sizeof(Oid) * nrelids;
592 
593  relids = (Oid *) MemoryContextAlloc(rb->context, alloc_len);
594 
595  return relids;
596 }
size_t Size
Definition: c.h:540
unsigned int Oid
Definition: postgres_ext.h:31

References ReorderBuffer::context, and MemoryContextAlloc().

Referenced by DecodeTruncate(), and ReorderBufferRestoreChange().

◆ ReorderBufferGetTupleBuf()

ReorderBufferTupleBuf* ReorderBufferGetTupleBuf ( ReorderBuffer rb,
Size  tuple_len 
)

Definition at line 550 of file reorderbuffer.c.

551 {
552  ReorderBufferTupleBuf *tuple;
553  Size alloc_len;
554 
555  alloc_len = tuple_len + SizeofHeapTupleHeader;
556 
557  tuple = (ReorderBufferTupleBuf *)
559  sizeof(ReorderBufferTupleBuf) +
560  MAXIMUM_ALIGNOF + alloc_len);
561  tuple->alloc_tuple_size = alloc_len;
562  tuple->tuple.t_data = ReorderBufferTupleBufData(tuple);
563 
564  return tuple;
565 }
#define SizeofHeapTupleHeader
Definition: htup_details.h:184
#define ReorderBufferTupleBufData(p)
Definition: reorderbuffer.h:38
HeapTupleHeader t_data
Definition: htup.h:68
HeapTupleData tuple
Definition: reorderbuffer.h:29

References ReorderBufferTupleBuf::alloc_tuple_size, MemoryContextAlloc(), ReorderBufferTupleBufData, SizeofHeapTupleHeader, HeapTupleData::t_data, ReorderBuffer::tup_context, and ReorderBufferTupleBuf::tuple.

Referenced by DecodeDelete(), DecodeInsert(), DecodeMultiInsert(), DecodeUpdate(), and ReorderBufferRestoreChange().

◆ ReorderBufferImmediateInvalidation()

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

Definition at line 2987 of file reorderbuffer.c.

2989 {
2990  bool use_subtxn = IsTransactionOrTransactionBlock();
2991  int i;
2992 
2993  if (use_subtxn)
2994  BeginInternalSubTransaction("replay");
2995 
2996  /*
2997  * Force invalidations to happen outside of a valid transaction - that way
2998  * entries will just be marked as invalid without accessing the catalog.
2999  * That's advantageous because we don't need to setup the full state
3000  * necessary for catalog access.
3001  */
3002  if (use_subtxn)
3004 
3005  for (i = 0; i < ninvalidations; i++)
3006  LocalExecuteInvalidationMessage(&invalidations[i]);
3007 
3008  if (use_subtxn)
3010 }
void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
Definition: inval.c:615
int i
Definition: isn.c:73
bool IsTransactionOrTransactionBlock(void)
Definition: xact.c:4784
void BeginInternalSubTransaction(const char *name)
Definition: xact.c:4490
void RollbackAndReleaseCurrentSubTransaction(void)
Definition: xact.c:4595
void AbortCurrentTransaction(void)
Definition: xact.c:3293

References AbortCurrentTransaction(), BeginInternalSubTransaction(), i, IsTransactionOrTransactionBlock(), LocalExecuteInvalidationMessage(), and RollbackAndReleaseCurrentSubTransaction().

Referenced by ReorderBufferAbort(), ReorderBufferForget(), ReorderBufferInvalidate(), and xact_decode().

◆ ReorderBufferInvalidate()

void ReorderBufferInvalidate ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn 
)

Definition at line 2956 of file reorderbuffer.c.

2957 {
2958  ReorderBufferTXN *txn;
2959 
2960  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
2961  false);
2962 
2963  /* unknown, nothing to do */
2964  if (txn == NULL)
2965  return;
2966 
2967  /*
2968  * Process cache invalidation messages if there are any. Even if we're not
2969  * interested in the transaction's contents, it could have manipulated the
2970  * catalog and we need to update the caches according to that.
2971  */
2972  if (txn->base_snapshot != NULL && txn->ninvalidations > 0)
2974  txn->invalidations);
2975  else
2976  Assert(txn->ninvalidations == 0);
2977 }

References Assert(), ReorderBufferTXN::base_snapshot, ReorderBufferTXN::invalidations, InvalidXLogRecPtr, ReorderBufferTXN::ninvalidations, ReorderBufferImmediateInvalidation(), and ReorderBufferTXNByXid().

Referenced by DecodePrepare().

◆ ReorderBufferPrepare()

void ReorderBufferPrepare ( ReorderBuffer rb,
TransactionId  xid,
char *  gid 
)

Definition at line 2707 of file reorderbuffer.c.

2709 {
2710  ReorderBufferTXN *txn;
2711 
2712  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
2713  false);
2714 
2715  /* unknown transaction, nothing to replay */
2716  if (txn == NULL)
2717  return;
2718 
2719  txn->txn_flags |= RBTXN_PREPARE;
2720  txn->gid = pstrdup(gid);
2721 
2722  /* The prepare info must have been updated in txn by now. */
2724 
2725  ReorderBufferReplay(txn, rb, xid, txn->final_lsn, txn->end_lsn,
2726  txn->xact_time.prepare_time, txn->origin_id, txn->origin_lsn);
2727 
2728  /*
2729  * We send the prepare for the concurrently aborted xacts so that later
2730  * when rollback prepared is decoded and sent, the downstream should be
2731  * able to rollback such a xact. See comments atop DecodePrepare.
2732  *
2733  * Note, for the concurrent_abort + streaming case a stream_prepare was
2734  * already sent within the ReorderBufferReplay call above.
2735  */
2736  if (txn->concurrent_abort && !rbtxn_is_streamed(txn))
2737  rb->prepare(rb, txn, txn->final_lsn);
2738 }
ReorderBufferPrepareCB prepare

References Assert(), ReorderBufferTXN::concurrent_abort, ReorderBufferTXN::end_lsn, ReorderBufferTXN::final_lsn, ReorderBufferTXN::gid, InvalidXLogRecPtr, ReorderBufferTXN::origin_id, ReorderBufferTXN::origin_lsn, ReorderBuffer::prepare, ReorderBufferTXN::prepare_time, pstrdup(), rbtxn_is_streamed, RBTXN_PREPARE, ReorderBufferReplay(), ReorderBufferTXNByXid(), ReorderBufferTXN::txn_flags, and ReorderBufferTXN::xact_time.

Referenced by DecodePrepare().

◆ ReorderBufferProcessXid()

void ReorderBufferProcessXid ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn 
)

Definition at line 3023 of file reorderbuffer.c.

3024 {
3025  /* many records won't have an xid assigned, centralize check here */
3026  if (xid != InvalidTransactionId)
3027  ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
3028 }

References InvalidTransactionId, and ReorderBufferTXNByXid().

Referenced by heap2_decode(), heap_decode(), LogicalDecodingProcessRecord(), logicalmsg_decode(), standby_decode(), xact_decode(), and xlog_decode().

◆ ReorderBufferQueueChange()

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

Definition at line 773 of file reorderbuffer.c.

775 {
776  ReorderBufferTXN *txn;
777 
778  txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
779 
780  /*
781  * While streaming the previous changes we have detected that the
782  * transaction is aborted. So there is no point in collecting further
783  * changes for it.
784  */
785  if (txn->concurrent_abort)
786  {
787  /*
788  * We don't need to update memory accounting for this change as we
789  * have not added it to the queue yet.
790  */
791  ReorderBufferReturnChange(rb, change, false);
792  return;
793  }
794 
795  change->lsn = lsn;
796  change->txn = txn;
797 
798  Assert(InvalidXLogRecPtr != lsn);
799  dlist_push_tail(&txn->changes, &change->node);
800  txn->nentries++;
801  txn->nentries_mem++;
802 
803  /* update memory accounting information */
804  ReorderBufferChangeMemoryUpdate(rb, change, true,
805  ReorderBufferChangeSize(change));
806 
807  /* process partial change */
808  ReorderBufferProcessPartialChange(rb, txn, change, toast_insert);
809 
810  /* check the memory limits and evict something if needed */
812 }
void ReorderBufferReturnChange(ReorderBuffer *rb, ReorderBufferChange *change, bool upd_mem)
static Size ReorderBufferChangeSize(ReorderBufferChange *change)
static void ReorderBufferProcessPartialChange(ReorderBuffer *rb, ReorderBufferTXN *txn, ReorderBufferChange *change, bool toast_insert)
static void ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
static void ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb, ReorderBufferChange *change, bool addition, Size sz)
dlist_head changes

References Assert(), ReorderBufferTXN::changes, ReorderBufferTXN::concurrent_abort, dlist_push_tail(), InvalidXLogRecPtr, ReorderBufferChange::lsn, ReorderBufferTXN::nentries, ReorderBufferTXN::nentries_mem, ReorderBufferChange::node, ReorderBufferChangeMemoryUpdate(), ReorderBufferChangeSize(), ReorderBufferCheckMemoryLimit(), ReorderBufferProcessPartialChange(), ReorderBufferReturnChange(), ReorderBufferTXNByXid(), and ReorderBufferChange::txn.

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

◆ ReorderBufferQueueMessage()

void ReorderBufferQueueMessage ( ReorderBuffer rb,
TransactionId  xid,
Snapshot  snapshot,
XLogRecPtr  lsn,
bool  transactional,
const char *  prefix,
Size  message_size,
const char *  message 
)

Definition at line 819 of file reorderbuffer.c.

823 {
824  if (transactional)
825  {
826  MemoryContext oldcontext;
827  ReorderBufferChange *change;
828 
830 
831  oldcontext = MemoryContextSwitchTo(rb->context);
832 
833  change = ReorderBufferGetChange(rb);
835  change->data.msg.prefix = pstrdup(prefix);
836  change->data.msg.message_size = message_size;
837  change->data.msg.message = palloc(message_size);
838  memcpy(change->data.msg.message, message, message_size);
839 
840  ReorderBufferQueueChange(rb, xid, lsn, change, false);
841 
842  MemoryContextSwitchTo(oldcontext);
843  }
844  else
845  {
846  ReorderBufferTXN *txn = NULL;
847  volatile Snapshot snapshot_now = snapshot;
848 
849  if (xid != InvalidTransactionId)
850  txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
851 
852  /* setup snapshot to allow catalog access */
853  SetupHistoricSnapshot(snapshot_now, NULL);
854  PG_TRY();
855  {
856  rb->message(rb, txn, lsn, false, prefix, message_size, message);
857 
859  }
860  PG_CATCH();
861  {
863  PG_RE_THROW();
864  }
865  PG_END_TRY();
866  }
867 }
#define PG_RE_THROW()
Definition: elog.h:340
#define PG_END_TRY()
Definition: elog.h:324
#define PG_TRY()
Definition: elog.h:299
#define PG_CATCH()
Definition: elog.h:309
void TeardownHistoricSnapshot(bool is_error)
Definition: snapmgr.c:2094
void SetupHistoricSnapshot(Snapshot historic_snapshot, HTAB *tuplecids)
Definition: snapmgr.c:2078
struct ReorderBufferChange::@105::@108 msg
ReorderBufferMessageCB message

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

Referenced by logicalmsg_decode().

◆ ReorderBufferRememberPrepareInfo()

bool ReorderBufferRememberPrepareInfo ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  prepare_lsn,
XLogRecPtr  end_lsn,
TimestampTz  prepare_time,
RepOriginId  origin_id,
XLogRecPtr  origin_lsn 
)

Definition at line 2660 of file reorderbuffer.c.

2664 {
2665  ReorderBufferTXN *txn;
2666 
2667  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr, false);
2668 
2669  /* unknown transaction, nothing to do */
2670  if (txn == NULL)
2671  return false;
2672 
2673  /*
2674  * Remember the prepare information to be later used by commit prepared in
2675  * case we skip doing prepare.
2676  */
2677  txn->final_lsn = prepare_lsn;
2678  txn->end_lsn = end_lsn;
2679  txn->xact_time.prepare_time = prepare_time;
2680  txn->origin_id = origin_id;
2681  txn->origin_lsn = origin_lsn;
2682 
2683  return true;
2684 }

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

Referenced by DecodePrepare().

◆ ReorderBufferReturnChange()

void ReorderBufferReturnChange ( ReorderBuffer rb,
ReorderBufferChange change,
bool  upd_mem 
)

Definition at line 480 of file reorderbuffer.c.

482 {
483  /* update memory accounting info */
484  if (upd_mem)
485  ReorderBufferChangeMemoryUpdate(rb, change, false,
486  ReorderBufferChangeSize(change));
487 
488  /* free contained data */
489  switch (change->action)
490  {
495  if (change->data.tp.newtuple)
496  {
497  ReorderBufferReturnTupleBuf(rb, change->data.tp.newtuple);
498  change->data.tp.newtuple = NULL;
499  }
500 
501  if (change->data.tp.oldtuple)
502  {
503  ReorderBufferReturnTupleBuf(rb, change->data.tp.oldtuple);
504  change->data.tp.oldtuple = NULL;
505  }
506  break;
508  if (change->data.msg.prefix != NULL)
509  pfree(change->data.msg.prefix);
510  change->data.msg.prefix = NULL;
511  if (change->data.msg.message != NULL)
512  pfree(change->data.msg.message);
513  change->data.msg.message = NULL;
514  break;
516  if (change->data.inval.invalidations)
517  pfree(change->data.inval.invalidations);
518  change->data.inval.invalidations = NULL;
519  break;
521  if (change->data.snapshot)
522  {
523  ReorderBufferFreeSnap(rb, change->data.snapshot);
524  change->data.snapshot = NULL;
525  }
526  break;
527  /* no data in addition to the struct itself */
529  if (change->data.truncate.relids != NULL)
530  {
531  ReorderBufferReturnRelids(rb, change->data.truncate.relids);
532  change->data.truncate.relids = NULL;
533  }
534  break;
539  break;
540  }
541 
542  pfree(change);
543 }
void pfree(void *pointer)
Definition: mcxt.c:1175
void ReorderBufferReturnTupleBuf(ReorderBuffer *rb, ReorderBufferTupleBuf *tuple)
static void ReorderBufferFreeSnap(ReorderBuffer *rb, Snapshot snap)
void ReorderBufferReturnRelids(ReorderBuffer *rb, Oid *relids)
struct ReorderBufferChange::@105::@107 truncate
struct ReorderBufferChange::@105::@106 tp

References ReorderBufferChange::action, ReorderBufferChange::data, ReorderBufferChange::inval, ReorderBufferChange::msg, pfree(), 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(), ReorderBufferFreeSnap(), ReorderBufferReturnRelids(), ReorderBufferReturnTupleBuf(), ReorderBufferChange::snapshot, ReorderBufferChange::tp, and ReorderBufferChange::truncate.

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

◆ ReorderBufferReturnRelids()

void ReorderBufferReturnRelids ( ReorderBuffer rb,
Oid relids 
)

Definition at line 602 of file reorderbuffer.c.

603 {
604  pfree(relids);
605 }

References pfree().

Referenced by ReorderBufferReturnChange().

◆ ReorderBufferReturnTupleBuf()

void ReorderBufferReturnTupleBuf ( ReorderBuffer rb,
ReorderBufferTupleBuf tuple 
)

Definition at line 571 of file reorderbuffer.c.

572 {
573  pfree(tuple);
574 }

References pfree().

Referenced by ReorderBufferReturnChange().

◆ ReorderBufferSetBaseSnapshot()

void ReorderBufferSetBaseSnapshot ( ReorderBuffer ,
TransactionId  ,
XLogRecPtr  lsn,
struct SnapshotData snap 
)

◆ ReorderBufferSetRestartPoint()

void ReorderBufferSetRestartPoint ( ReorderBuffer rb,
XLogRecPtr  ptr 
)

Definition at line 1009 of file reorderbuffer.c.

1010 {
1011  rb->current_restart_decoding_lsn = ptr;
1012 }

References ReorderBuffer::current_restart_decoding_lsn.

Referenced by SnapBuildRestore(), and SnapBuildSerialize().

◆ ReorderBufferSkipPrepare()

void ReorderBufferSkipPrepare ( ReorderBuffer rb,
TransactionId  xid 
)

Definition at line 2688 of file reorderbuffer.c.

2689 {
2690  ReorderBufferTXN *txn;
2691 
2692  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr, false);
2693 
2694  /* unknown transaction, nothing to do */
2695  if (txn == NULL)
2696  return;
2697 
2699 }

References InvalidXLogRecPtr, RBTXN_SKIPPED_PREPARE, ReorderBufferTXNByXid(), and ReorderBufferTXN::txn_flags.

Referenced by DecodePrepare().

◆ ReorderBufferXidHasBaseSnapshot()

bool ReorderBufferXidHasBaseSnapshot ( ReorderBuffer rb,
TransactionId  xid 
)

Definition at line 3315 of file reorderbuffer.c.

3316 {
3317  ReorderBufferTXN *txn;
3318 
3319  txn = ReorderBufferTXNByXid(rb, xid, false,
3320  NULL, InvalidXLogRecPtr, false);
3321 
3322  /* transaction isn't known yet, ergo no snapshot */
3323  if (txn == NULL)
3324  return false;
3325 
3326  /* a known subtxn? operate on top-level txn instead */
3327  if (rbtxn_is_known_subxact(txn))
3328  txn = ReorderBufferTXNByXid(rb, txn->toplevel_xid, false,
3329  NULL, InvalidXLogRecPtr, false);
3330 
3331  return txn->base_snapshot != NULL;
3332 }

References ReorderBufferTXN::base_snapshot, InvalidXLogRecPtr, rbtxn_is_known_subxact, ReorderBufferTXNByXid(), and ReorderBufferTXN::toplevel_xid.

Referenced by SnapBuildCommitTxn(), SnapBuildDistributeNewCatalogSnapshot(), and SnapBuildProcessChange().

◆ ReorderBufferXidHasCatalogChanges()

bool ReorderBufferXidHasCatalogChanges ( ReorderBuffer rb,
TransactionId  xid 
)

Definition at line 3298 of file reorderbuffer.c.

3299 {
3300  ReorderBufferTXN *txn;
3301 
3302  txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
3303  false);
3304  if (txn == NULL)
3305  return false;
3306 
3307  return rbtxn_has_catalog_changes(txn);
3308 }
#define rbtxn_has_catalog_changes(txn)

References InvalidXLogRecPtr, rbtxn_has_catalog_changes, and ReorderBufferTXNByXid().

Referenced by SnapBuildCommitTxn().

◆ ReorderBufferXidSetCatalogChanges()

void ReorderBufferXidSetCatalogChanges ( ReorderBuffer rb,
TransactionId  xid,
XLogRecPtr  lsn 
)

Definition at line 3274 of file reorderbuffer.c.

3276 {
3277  ReorderBufferTXN *txn;
3278 
3279  txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
3280 
3282 
3283  /*
3284  * Mark top-level transaction as having catalog changes too if one of its
3285  * children has so that the ReorderBufferBuildTupleCidHash can
3286  * conveniently check just top-level transaction and decide whether to
3287  * build the hash table or not.
3288  */
3289  if (txn->toptxn != NULL)
3291 }

References RBTXN_HAS_CATALOG_CHANGES, ReorderBufferTXNByXid(), ReorderBufferTXN::toptxn, and ReorderBufferTXN::txn_flags.

Referenced by heap_decode(), SnapBuildProcessNewCid(), and xact_decode().

◆ StartupReorderBuffer()

void StartupReorderBuffer ( void  )

Definition at line 4462 of file reorderbuffer.c.

4463 {
4464  DIR *logical_dir;
4465  struct dirent *logical_de;
4466 
4467  logical_dir = AllocateDir("pg_replslot");
4468  while ((logical_de = ReadDir(logical_dir, "pg_replslot")) != NULL)
4469  {
4470  if (strcmp(logical_de->d_name, ".") == 0 ||
4471  strcmp(logical_de->d_name, "..") == 0)
4472  continue;
4473 
4474  /* if it cannot be a slot, skip the directory */
4475  if (!ReplicationSlotValidateName(logical_de->d_name, DEBUG2))
4476  continue;
4477 
4478  /*
4479  * ok, has to be a surviving logical slot, iterate and delete
4480  * everything starting with xid-*
4481  */
4483  }
4484  FreeDir(logical_dir);
4485 }
struct dirent * ReadDir(DIR *dir, const char *dirname)
Definition: fd.c:2788
int FreeDir(DIR *dir)
Definition: fd.c:2840
DIR * AllocateDir(const char *dirname)
Definition: fd.c:2722
bool ReplicationSlotValidateName(const char *name, int elevel)
Definition: slot.c:201
Definition: dirent.c:26
Definition: dirent.h:10
char d_name[MAX_PATH]
Definition: dirent.h:15

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

Referenced by StartupXLOG().

Variable Documentation

◆ logical_decoding_work_mem

PGDLLIMPORT int logical_decoding_work_mem
extern

Definition at line 209 of file reorderbuffer.c.

Referenced by ReorderBufferCheckMemoryLimit().