PostgreSQL Source Code  git master
reorderbuffer.h
Go to the documentation of this file.
1 /*
2  * reorderbuffer.h
3  * PostgreSQL logical replay/reorder buffer management.
4  *
5  * Copyright (c) 2012-2024, PostgreSQL Global Development Group
6  *
7  * src/include/replication/reorderbuffer.h
8  */
9 #ifndef REORDERBUFFER_H
10 #define REORDERBUFFER_H
11 
12 #include "access/htup_details.h"
13 #include "lib/ilist.h"
14 #include "lib/pairingheap.h"
15 #include "storage/sinval.h"
16 #include "utils/hsearch.h"
17 #include "utils/relcache.h"
18 #include "utils/snapshot.h"
19 #include "utils/timestamp.h"
20 
21 /* paths for logical decoding data (relative to installation's $PGDATA) */
22 #define PG_LOGICAL_DIR "pg_logical"
23 #define PG_LOGICAL_MAPPINGS_DIR PG_LOGICAL_DIR "/mappings"
24 #define PG_LOGICAL_SNAPSHOTS_DIR PG_LOGICAL_DIR "/snapshots"
25 
26 /* GUC variables */
29 
30 /* possible values for debug_logical_replication_streaming */
31 typedef enum
32 {
36 
37 /*
38  * Types of the change passed to a 'change' callback.
39  *
40  * For efficiency and simplicity reasons we want to keep Snapshots, CommandIds
41  * and ComboCids in the same list with the user visible INSERT/UPDATE/DELETE
42  * changes. Users of the decoding facilities will never see changes with
43  * *_INTERNAL_* actions.
44  *
45  * The INTERNAL_SPEC_INSERT and INTERNAL_SPEC_CONFIRM, and INTERNAL_SPEC_ABORT
46  * changes concern "speculative insertions", their confirmation, and abort
47  * respectively. They're used by INSERT .. ON CONFLICT .. UPDATE. Users of
48  * logical decoding don't have to care about these.
49  */
51 {
65 
66 /* forward declaration */
67 struct ReorderBufferTXN;
68 
69 /*
70  * a single 'change', can be an insert (with one tuple), an update (old, new),
71  * or a delete (old).
72  *
73  * The same struct is also used internally for other purposes but that should
74  * never be visible outside reorderbuffer.c.
75  */
76 typedef struct ReorderBufferChange
77 {
79 
80  /* The type of change. */
82 
83  /* Transaction this change belongs to. */
85 
87 
88  /*
89  * Context data for the change. Which part of the union is valid depends
90  * on action.
91  */
92  union
93  {
94  /* Old, new tuples when action == *_INSERT|UPDATE|DELETE */
95  struct
96  {
97  /* relation that has been changed */
99 
100  /* no previously reassembled toast chunks are necessary anymore */
102 
103  /* valid for DELETE || UPDATE */
105  /* valid for INSERT || UPDATE */
107  } tp;
108 
109  /*
110  * Truncate data for REORDER_BUFFER_CHANGE_TRUNCATE representing one
111  * set of relations to be truncated.
112  */
113  struct
114  {
116  bool cascade;
120 
121  /* Message with arbitrary data. */
122  struct
123  {
124  char *prefix;
126  char *message;
127  } msg;
128 
129  /* New snapshot, set when action == *_INTERNAL_SNAPSHOT */
131 
132  /*
133  * New command id for existing snapshot in a catalog changing tx. Set
134  * when action == *_INTERNAL_COMMAND_ID.
135  */
137 
138  /*
139  * New cid mapping for catalog changing transaction, set when action
140  * == *_INTERNAL_TUPLECID.
141  */
142  struct
143  {
150 
151  /* Invalidation. */
152  struct
153  {
154  uint32 ninvalidations; /* Number of messages */
155  SharedInvalidationMessage *invalidations; /* invalidation message */
156  } inval;
157  } data;
158 
159  /*
160  * While in use this is how a change is linked into a transactions,
161  * otherwise it's the preallocated list.
162  */
165 
166 /* ReorderBufferTXN txn_flags */
167 #define RBTXN_HAS_CATALOG_CHANGES 0x0001
168 #define RBTXN_IS_SUBXACT 0x0002
169 #define RBTXN_IS_SERIALIZED 0x0004
170 #define RBTXN_IS_SERIALIZED_CLEAR 0x0008
171 #define RBTXN_IS_STREAMED 0x0010
172 #define RBTXN_HAS_PARTIAL_CHANGE 0x0020
173 #define RBTXN_PREPARE 0x0040
174 #define RBTXN_SKIPPED_PREPARE 0x0080
175 #define RBTXN_HAS_STREAMABLE_CHANGE 0x0100
176 
177 /* Does the transaction have catalog changes? */
178 #define rbtxn_has_catalog_changes(txn) \
179 ( \
180  ((txn)->txn_flags & RBTXN_HAS_CATALOG_CHANGES) != 0 \
181 )
182 
183 /* Is the transaction known as a subxact? */
184 #define rbtxn_is_known_subxact(txn) \
185 ( \
186  ((txn)->txn_flags & RBTXN_IS_SUBXACT) != 0 \
187 )
188 
189 /* Has this transaction been spilled to disk? */
190 #define rbtxn_is_serialized(txn) \
191 ( \
192  ((txn)->txn_flags & RBTXN_IS_SERIALIZED) != 0 \
193 )
194 
195 /* Has this transaction ever been spilled to disk? */
196 #define rbtxn_is_serialized_clear(txn) \
197 ( \
198  ((txn)->txn_flags & RBTXN_IS_SERIALIZED_CLEAR) != 0 \
199 )
200 
201 /* Has this transaction contains partial changes? */
202 #define rbtxn_has_partial_change(txn) \
203 ( \
204  ((txn)->txn_flags & RBTXN_HAS_PARTIAL_CHANGE) != 0 \
205 )
206 
207 /* Does this transaction contain streamable changes? */
208 #define rbtxn_has_streamable_change(txn) \
209 ( \
210  ((txn)->txn_flags & RBTXN_HAS_STREAMABLE_CHANGE) != 0 \
211 )
212 
213 /*
214  * Has this transaction been streamed to downstream?
215  *
216  * (It's not possible to deduce this from nentries and nentries_mem for
217  * various reasons. For example, all changes may be in subtransactions in
218  * which case we'd have nentries==0 for the toplevel one, which would say
219  * nothing about the streaming. So we maintain this flag, but only for the
220  * toplevel transaction.)
221  */
222 #define rbtxn_is_streamed(txn) \
223 ( \
224  ((txn)->txn_flags & RBTXN_IS_STREAMED) != 0 \
225 )
226 
227 /* Has this transaction been prepared? */
228 #define rbtxn_prepared(txn) \
229 ( \
230  ((txn)->txn_flags & RBTXN_PREPARE) != 0 \
231 )
232 
233 /* prepare for this transaction skipped? */
234 #define rbtxn_skip_prepared(txn) \
235 ( \
236  ((txn)->txn_flags & RBTXN_SKIPPED_PREPARE) != 0 \
237 )
238 
239 /* Is this a top-level transaction? */
240 #define rbtxn_is_toptxn(txn) \
241 ( \
242  (txn)->toptxn == NULL \
243 )
244 
245 /* Is this a subtransaction? */
246 #define rbtxn_is_subtxn(txn) \
247 ( \
248  (txn)->toptxn != NULL \
249 )
250 
251 /* Get the top-level transaction of this (sub)transaction. */
252 #define rbtxn_get_toptxn(txn) \
253 ( \
254  rbtxn_is_subtxn(txn) ? (txn)->toptxn : (txn) \
255 )
256 
257 typedef struct ReorderBufferTXN
258 {
259  /* See above */
261 
262  /* The transaction's transaction id, can be a toplevel or sub xid. */
264 
265  /* Xid of top-level transaction, if known */
267 
268  /*
269  * Global transaction id required for identification of prepared
270  * transactions.
271  */
272  char *gid;
273 
274  /*
275  * LSN of the first data carrying, WAL record with knowledge about this
276  * xid. This is allowed to *not* be first record adorned with this xid, if
277  * the previous records aren't relevant for logical decoding.
278  */
280 
281  /* ----
282  * LSN of the record that lead to this xact to be prepared or committed or
283  * aborted. This can be a
284  * * plain commit record
285  * * plain commit record, of a parent transaction
286  * * prepared transaction
287  * * prepared transaction commit
288  * * plain abort record
289  * * prepared transaction abort
290  *
291  * This can also become set to earlier values than transaction end when
292  * a transaction is spilled to disk; specifically it's set to the LSN of
293  * the latest change written to disk so far.
294  * ----
295  */
297 
298  /*
299  * LSN pointing to the end of the commit record + 1.
300  */
302 
303  /* Toplevel transaction for this subxact (NULL for top-level). */
305 
306  /*
307  * LSN of the last lsn at which snapshot information reside, so we can
308  * restart decoding from there and fully recover this transaction from
309  * WAL.
310  */
312 
313  /* origin of the change that caused this transaction */
316 
317  /*
318  * Commit or Prepare time, only known when we read the actual commit or
319  * prepare record.
320  */
321  union
322  {
327 
328  /*
329  * The base snapshot is used to decode all changes until either this
330  * transaction modifies the catalog, or another catalog-modifying
331  * transaction commits.
332  */
335  dlist_node base_snapshot_node; /* link in txns_by_base_snapshot_lsn */
336 
337  /*
338  * Snapshot/CID from the previous streaming run. Only valid for already
339  * streamed transactions (NULL/InvalidCommandId otherwise).
340  */
343 
344  /*
345  * How many ReorderBufferChange's do we have in this txn.
346  *
347  * Changes in subtransactions are *not* included but tracked separately.
348  */
349  uint64 nentries;
350 
351  /*
352  * How many of the above entries are stored in memory in contrast to being
353  * spilled to disk.
354  */
355  uint64 nentries_mem;
356 
357  /*
358  * List of ReorderBufferChange structs, including new Snapshots, new
359  * CommandIds and command invalidation messages.
360  */
362 
363  /*
364  * List of (relation, ctid) => (cmin, cmax) mappings for catalog tuples.
365  * Those are always assigned to the toplevel transaction. (Keep track of
366  * #entries to create a hash of the right size)
367  */
369  uint64 ntuplecids;
370 
371  /*
372  * On-demand built hash for looking up the above values.
373  */
375 
376  /*
377  * Hash containing (potentially partial) toast entries. NULL if no toast
378  * tuples have been found for the current change.
379  */
381 
382  /*
383  * non-hierarchical list of subtransactions that are *not* aborted. Only
384  * used in toplevel transactions.
385  */
388 
389  /*
390  * Stored cache invalidations. This is not a linked list because we get
391  * all the invalidations at once.
392  */
395 
396  /* ---
397  * Position in one of two lists:
398  * * list of subtransactions if we are *known* to be subxact
399  * * list of toplevel xacts (can be an as-yet unknown subxact)
400  * ---
401  */
403 
404  /*
405  * A node in the list of catalog modifying transactions
406  */
408 
409  /*
410  * A node in txn_heap
411  */
413 
414  /*
415  * Size of this transaction (changes currently in memory, in bytes).
416  */
418 
419  /* Size of top-transaction including sub-transactions. */
421 
422  /* If we have detected concurrent abort then ignore future changes. */
424 
425  /*
426  * Private data pointer of the output plugin.
427  */
430 
431 /* so we can define the callbacks used inside struct ReorderBuffer itself */
432 typedef struct ReorderBuffer ReorderBuffer;
433 
434 /* change callback signature */
436  ReorderBufferTXN *txn,
437  Relation relation,
438  ReorderBufferChange *change);
439 
440 /* truncate callback signature */
442  ReorderBufferTXN *txn,
443  int nrelations,
444  Relation relations[],
445  ReorderBufferChange *change);
446 
447 /* begin callback signature */
448 typedef void (*ReorderBufferBeginCB) (ReorderBuffer *rb,
449  ReorderBufferTXN *txn);
450 
451 /* commit callback signature */
453  ReorderBufferTXN *txn,
454  XLogRecPtr commit_lsn);
455 
456 /* message callback signature */
458  ReorderBufferTXN *txn,
459  XLogRecPtr message_lsn,
460  bool transactional,
461  const char *prefix, Size sz,
462  const char *message);
463 
464 /* begin prepare callback signature */
466  ReorderBufferTXN *txn);
467 
468 /* prepare callback signature */
470  ReorderBufferTXN *txn,
471  XLogRecPtr prepare_lsn);
472 
473 /* commit prepared callback signature */
475  ReorderBufferTXN *txn,
476  XLogRecPtr commit_lsn);
477 
478 /* rollback prepared callback signature */
480  ReorderBufferTXN *txn,
481  XLogRecPtr prepare_end_lsn,
482  TimestampTz prepare_time);
483 
484 /* start streaming transaction callback signature */
485 typedef void (*ReorderBufferStreamStartCB) (
486  ReorderBuffer *rb,
487  ReorderBufferTXN *txn,
488  XLogRecPtr first_lsn);
489 
490 /* stop streaming transaction callback signature */
491 typedef void (*ReorderBufferStreamStopCB) (
492  ReorderBuffer *rb,
493  ReorderBufferTXN *txn,
494  XLogRecPtr last_lsn);
495 
496 /* discard streamed transaction callback signature */
497 typedef void (*ReorderBufferStreamAbortCB) (
498  ReorderBuffer *rb,
499  ReorderBufferTXN *txn,
500  XLogRecPtr abort_lsn);
501 
502 /* prepare streamed transaction callback signature */
504  ReorderBuffer *rb,
505  ReorderBufferTXN *txn,
506  XLogRecPtr prepare_lsn);
507 
508 /* commit streamed transaction callback signature */
510  ReorderBuffer *rb,
511  ReorderBufferTXN *txn,
512  XLogRecPtr commit_lsn);
513 
514 /* stream change callback signature */
516  ReorderBuffer *rb,
517  ReorderBufferTXN *txn,
518  Relation relation,
519  ReorderBufferChange *change);
520 
521 /* stream message callback signature */
523  ReorderBuffer *rb,
524  ReorderBufferTXN *txn,
525  XLogRecPtr message_lsn,
526  bool transactional,
527  const char *prefix, Size sz,
528  const char *message);
529 
530 /* stream truncate callback signature */
532  ReorderBuffer *rb,
533  ReorderBufferTXN *txn,
534  int nrelations,
535  Relation relations[],
536  ReorderBufferChange *change);
537 
538 /* update progress txn callback signature */
540  ReorderBuffer *rb,
541  ReorderBufferTXN *txn,
542  XLogRecPtr lsn);
543 
545 {
546  /*
547  * xid => ReorderBufferTXN lookup table
548  */
550 
551  /*
552  * Transactions that could be a toplevel xact, ordered by LSN of the first
553  * record bearing that xid.
554  */
556 
557  /*
558  * Transactions and subtransactions that have a base snapshot, ordered by
559  * LSN of the record which caused us to first obtain the base snapshot.
560  * This is not the same as toplevel_by_lsn, because we only set the base
561  * snapshot on the first logical-decoding-relevant record (eg. heap
562  * writes), whereas the initial LSN could be set by other operations.
563  */
565 
566  /*
567  * Transactions and subtransactions that have modified system catalogs.
568  */
570 
571  /*
572  * one-entry sized cache for by_txn. Very frequently the same txn gets
573  * looked up over and over again.
574  */
577 
578  /*
579  * Callbacks to be called when a transactions commits.
580  */
586 
587  /*
588  * Callbacks to be called when streaming a transaction at prepare time.
589  */
594 
595  /*
596  * Callbacks to be called when streaming a transaction.
597  */
606 
607  /*
608  * Callback to be called when updating progress during sending data of a
609  * transaction (and its subtransactions) to the output plugin.
610  */
612 
613  /*
614  * Pointer that will be passed untouched to the callbacks.
615  */
617 
618  /*
619  * Saved output plugin option
620  */
622 
623  /*
624  * Private memory context.
625  */
627 
628  /*
629  * Memory contexts for specific types objects
630  */
634 
636 
637  /* buffer for disk<->memory conversions */
638  char *outbuf;
640 
641  /* memory accounting */
643 
644  /* Max-heap for sizes of all top-level and sub transactions */
646 
647  /*
648  * Statistics about transactions spilled to disk.
649  *
650  * A single transaction may be spilled repeatedly, which is why we keep
651  * two different counters. For spilling, the transaction counter includes
652  * both toplevel transactions and subtransactions.
653  */
654  int64 spillTxns; /* number of transactions spilled to disk */
655  int64 spillCount; /* spill-to-disk invocation counter */
656  int64 spillBytes; /* amount of data spilled to disk */
657 
658  /* Statistics about transactions streamed to the decoding output plugin */
659  int64 streamTxns; /* number of transactions streamed */
660  int64 streamCount; /* streaming invocation counter */
661  int64 streamBytes; /* amount of data decoded */
662 
663  /*
664  * Statistics about all the transactions sent to the decoding output
665  * plugin
666  */
667  int64 totalTxns; /* total number of transactions sent */
668  int64 totalBytes; /* total amount of data decoded */
669 };
670 
671 
673 extern void ReorderBufferFree(ReorderBuffer *rb);
674 
676  Size tuple_len);
677 extern void ReorderBufferReturnTupleBuf(HeapTuple tuple);
678 
681  ReorderBufferChange *change, bool upd_mem);
682 
683 extern Oid *ReorderBufferGetRelids(ReorderBuffer *rb, int nrelids);
684 extern void ReorderBufferReturnRelids(ReorderBuffer *rb, Oid *relids);
685 
687  XLogRecPtr lsn, ReorderBufferChange *change,
688  bool toast_insert);
690  Snapshot snap, XLogRecPtr lsn,
691  bool transactional, const char *prefix,
692  Size message_size, const char *message);
693 extern void ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
694  XLogRecPtr commit_lsn, XLogRecPtr end_lsn,
695  TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn);
697  XLogRecPtr commit_lsn, XLogRecPtr end_lsn,
698  XLogRecPtr two_phase_at,
699  TimestampTz commit_time,
700  RepOriginId origin_id, XLogRecPtr origin_lsn,
701  char *gid, bool is_commit);
703  TransactionId subxid, XLogRecPtr lsn);
705  TransactionId subxid, XLogRecPtr commit_lsn,
706  XLogRecPtr end_lsn);
707 extern void ReorderBufferAbort(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn,
708  TimestampTz abort_time);
709 extern void ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid);
710 extern void ReorderBufferForget(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn);
712 
714  XLogRecPtr lsn, Snapshot snap);
716  XLogRecPtr lsn, Snapshot snap);
718  XLogRecPtr lsn, CommandId cid);
720  XLogRecPtr lsn, RelFileLocator locator,
721  ItemPointerData tid,
722  CommandId cmin, CommandId cmax, CommandId combocid);
724  Size nmsgs, SharedInvalidationMessage *msgs);
725 extern void ReorderBufferImmediateInvalidation(ReorderBuffer *rb, uint32 ninvalidations,
726  SharedInvalidationMessage *invalidations);
728 
732 
734  XLogRecPtr prepare_lsn, XLogRecPtr end_lsn,
735  TimestampTz prepare_time,
736  RepOriginId origin_id, XLogRecPtr origin_lsn);
738 extern void ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid, char *gid);
742 
744 
745 extern void StartupReorderBuffer(void);
746 
747 #endif
unsigned int uint32
Definition: c.h:506
#define PGDLLIMPORT
Definition: c.h:1307
uint32 bits32
Definition: c.h:514
uint32 CommandId
Definition: c.h:657
uint32 TransactionId
Definition: c.h:643
size_t Size
Definition: c.h:596
int64 TimestampTz
Definition: timestamp.h:39
unsigned int Oid
Definition: postgres_ext.h:31
void ReorderBufferReturnChange(ReorderBuffer *rb, ReorderBufferChange *change, bool upd_mem)
void(* ReorderBufferCommitCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
TransactionId * ReorderBufferGetCatalogChangesXacts(ReorderBuffer *rb)
PGDLLIMPORT int logical_decoding_work_mem
void ReorderBufferXidSetCatalogChanges(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferAddNewCommandId(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, CommandId cid)
PGDLLIMPORT int debug_logical_replication_streaming
void ReorderBufferAddNewTupleCids(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, RelFileLocator locator, ItemPointerData tid, CommandId cmin, CommandId cmax, CommandId combocid)
void ReorderBufferSetBaseSnapshot(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Snapshot snap)
void ReorderBufferAbort(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, TimestampTz abort_time)
HeapTuple ReorderBufferGetTupleBuf(ReorderBuffer *rb, Size tuple_len)
void(* ReorderBufferUpdateProgressTxnCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr lsn)
void(* ReorderBufferStreamCommitCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
bool ReorderBufferXidHasCatalogChanges(ReorderBuffer *rb, TransactionId xid)
void ReorderBufferInvalidate(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
TransactionId ReorderBufferGetOldestXmin(ReorderBuffer *rb)
void(* ReorderBufferStreamStartCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr first_lsn)
void(* ReorderBufferApplyChangeCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
struct ReorderBufferTXN ReorderBufferTXN
void(* ReorderBufferStreamPrepareCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
void(* ReorderBufferStreamChangeCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
DebugLogicalRepStreamingMode
Definition: reorderbuffer.h:32
@ DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE
Definition: reorderbuffer.h:34
@ DEBUG_LOGICAL_REP_STREAMING_BUFFERED
Definition: reorderbuffer.h:33
void ReorderBufferQueueChange(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, ReorderBufferChange *change, bool toast_insert)
void ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid, char *gid)
ReorderBuffer * ReorderBufferAllocate(void)
void(* ReorderBufferCommitPreparedCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
void(* ReorderBufferStreamMessageCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size sz, const char *message)
void ReorderBufferForget(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferCommitChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn)
void(* ReorderBufferBeginCB)(ReorderBuffer *rb, ReorderBufferTXN *txn)
void ReorderBufferSkipPrepare(ReorderBuffer *rb, TransactionId xid)
Oid * ReorderBufferGetRelids(ReorderBuffer *rb, int nrelids)
void(* ReorderBufferMessageCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size sz, const char *message)
struct ReorderBufferChange ReorderBufferChange
void ReorderBufferAddInvalidations(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Size nmsgs, SharedInvalidationMessage *msgs)
void(* ReorderBufferApplyTruncateCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
ReorderBufferTXN * ReorderBufferGetOldestTXN(ReorderBuffer *rb)
void(* ReorderBufferBeginPrepareCB)(ReorderBuffer *rb, ReorderBufferTXN *txn)
void ReorderBufferQueueMessage(ReorderBuffer *rb, TransactionId xid, Snapshot snap, XLogRecPtr lsn, bool transactional, const char *prefix, Size message_size, const char *message)
bool ReorderBufferXidHasBaseSnapshot(ReorderBuffer *rb, TransactionId xid)
ReorderBufferChange * ReorderBufferGetChange(ReorderBuffer *rb)
void ReorderBufferAddSnapshot(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Snapshot snap)
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(* ReorderBufferStreamAbortCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr abort_lsn)
void ReorderBufferReturnTupleBuf(HeapTuple tuple)
void ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn, TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn)
void ReorderBufferSetRestartPoint(ReorderBuffer *rb, XLogRecPtr ptr)
void(* ReorderBufferPrepareCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
bool ReorderBufferRememberPrepareInfo(ReorderBuffer *rb, TransactionId xid, XLogRecPtr prepare_lsn, XLogRecPtr end_lsn, TimestampTz prepare_time, RepOriginId origin_id, XLogRecPtr origin_lsn)
void ReorderBufferImmediateInvalidation(ReorderBuffer *rb, uint32 ninvalidations, SharedInvalidationMessage *invalidations)
void ReorderBufferReturnRelids(ReorderBuffer *rb, Oid *relids)
void(* ReorderBufferRollbackPreparedCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr prepare_end_lsn, TimestampTz prepare_time)
void ReorderBufferProcessXid(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr lsn)
void ReorderBufferFree(ReorderBuffer *rb)
ReorderBufferChangeType
Definition: reorderbuffer.h:51
@ REORDER_BUFFER_CHANGE_INVALIDATION
Definition: reorderbuffer.h:56
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM
Definition: reorderbuffer.h:61
@ REORDER_BUFFER_CHANGE_INSERT
Definition: reorderbuffer.h:52
@ REORDER_BUFFER_CHANGE_MESSAGE
Definition: reorderbuffer.h:55
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT
Definition: reorderbuffer.h:62
@ REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID
Definition: reorderbuffer.h:58
@ REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID
Definition: reorderbuffer.h:59
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT
Definition: reorderbuffer.h:60
@ REORDER_BUFFER_CHANGE_TRUNCATE
Definition: reorderbuffer.h:63
@ REORDER_BUFFER_CHANGE_DELETE
Definition: reorderbuffer.h:54
@ REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT
Definition: reorderbuffer.h:57
@ REORDER_BUFFER_CHANGE_UPDATE
Definition: reorderbuffer.h:53
void(* ReorderBufferStreamStopCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, XLogRecPtr last_lsn)
void StartupReorderBuffer(void)
void ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
void(* ReorderBufferStreamTruncateCB)(ReorderBuffer *rb, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
Definition: dynahash.c:220
ReorderBufferChangeType action
Definition: reorderbuffer.h:81
struct ReorderBufferChange::@105::@107 truncate
struct ReorderBufferChange::@105::@106 tp
RelFileLocator rlocator
Definition: reorderbuffer.h:98
ItemPointerData tid
union ReorderBufferChange::@105 data
struct ReorderBufferTXN * txn
Definition: reorderbuffer.h:84
RelFileLocator locator
RepOriginId origin_id
Definition: reorderbuffer.h:86
struct ReorderBufferChange::@105::@108 msg
struct ReorderBufferChange::@105::@110 inval
struct ReorderBufferChange::@105::@109 tuplecid
SharedInvalidationMessage * invalidations
CommandId command_id
XLogRecPtr restart_decoding_lsn
pairingheap_node txn_node
TimestampTz commit_time
XLogRecPtr base_snapshot_lsn
Snapshot snapshot_now
TransactionId toplevel_xid
dlist_node catchange_node
Snapshot base_snapshot
SharedInvalidationMessage * invalidations
RepOriginId origin_id
struct ReorderBufferTXN * toptxn
dlist_head tuplecids
XLogRecPtr first_lsn
TimestampTz abort_time
XLogRecPtr final_lsn
void * output_plugin_private
XLogRecPtr end_lsn
XLogRecPtr origin_lsn
TimestampTz prepare_time
TransactionId xid
dlist_node base_snapshot_node
dlist_head changes
union ReorderBufferTXN::@111 xact_time
dlist_head subtxns
ReorderBufferStreamMessageCB stream_message
ReorderBufferStreamChangeCB stream_change
ReorderBufferBeginCB begin_prepare
ReorderBufferStreamTruncateCB stream_truncate
ReorderBufferCommitPreparedCB commit_prepared
ReorderBufferUpdateProgressTxnCB update_progress_txn
ReorderBufferMessageCB message
dlist_head txns_by_base_snapshot_lsn
MemoryContext context
dclist_head catchange_txns
ReorderBufferRollbackPreparedCB rollback_prepared
ReorderBufferPrepareCB prepare
ReorderBufferStreamStopCB stream_stop
ReorderBufferApplyChangeCB apply_change
MemoryContext change_context
ReorderBufferTXN * by_txn_last_txn
TransactionId by_txn_last_xid
ReorderBufferStreamPrepareCB stream_prepare
ReorderBufferStreamAbortCB stream_abort
MemoryContext tup_context
ReorderBufferCommitCB commit
ReorderBufferStreamStartCB stream_start
ReorderBufferStreamCommitCB stream_commit
ReorderBufferApplyTruncateCB apply_truncate
dlist_head toplevel_by_lsn
pairingheap * txn_heap
ReorderBufferBeginCB begin
MemoryContext txn_context
XLogRecPtr current_restart_decoding_lsn
void * private_data
uint16 RepOriginId
Definition: xlogdefs.h:65
uint64 XLogRecPtr
Definition: xlogdefs.h:21