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-2023, 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 "storage/sinval.h"
15 #include "utils/hsearch.h"
16 #include "utils/relcache.h"
17 #include "utils/snapshot.h"
18 #include "utils/timestamp.h"
19 
20 /* GUC variables */
23 
24 /* possible values for debug_logical_replication_streaming */
25 typedef enum
26 {
30 
31 /* an individual tuple, stored in one chunk of memory */
32 typedef struct ReorderBufferTupleBuf
33 {
34  /* position in preallocated list */
36 
37  /* tuple header, the interesting bit for users of logical decoding */
39 
40  /* pre-allocated size of tuple buffer, different from tuple size */
42 
43  /* actual tuple data follows */
45 
46 /* pointer to the data stored in a TupleBuf */
47 #define ReorderBufferTupleBufData(p) \
48  ((HeapTupleHeader) MAXALIGN(((char *) p) + sizeof(ReorderBufferTupleBuf)))
49 
50 /*
51  * Types of the change passed to a 'change' callback.
52  *
53  * For efficiency and simplicity reasons we want to keep Snapshots, CommandIds
54  * and ComboCids in the same list with the user visible INSERT/UPDATE/DELETE
55  * changes. Users of the decoding facilities will never see changes with
56  * *_INTERNAL_* actions.
57  *
58  * The INTERNAL_SPEC_INSERT and INTERNAL_SPEC_CONFIRM, and INTERNAL_SPEC_ABORT
59  * changes concern "speculative insertions", their confirmation, and abort
60  * respectively. They're used by INSERT .. ON CONFLICT .. UPDATE. Users of
61  * logical decoding don't have to care about these.
62  */
64 {
78 
79 /* forward declaration */
80 struct ReorderBufferTXN;
81 
82 /*
83  * a single 'change', can be an insert (with one tuple), an update (old, new),
84  * or a delete (old).
85  *
86  * The same struct is also used internally for other purposes but that should
87  * never be visible outside reorderbuffer.c.
88  */
89 typedef struct ReorderBufferChange
90 {
92 
93  /* The type of change. */
95 
96  /* Transaction this change belongs to. */
98 
100 
101  /*
102  * Context data for the change. Which part of the union is valid depends
103  * on action.
104  */
105  union
106  {
107  /* Old, new tuples when action == *_INSERT|UPDATE|DELETE */
108  struct
109  {
110  /* relation that has been changed */
112 
113  /* no previously reassembled toast chunks are necessary anymore */
115 
116  /* valid for DELETE || UPDATE */
118  /* valid for INSERT || UPDATE */
120  } tp;
121 
122  /*
123  * Truncate data for REORDER_BUFFER_CHANGE_TRUNCATE representing one
124  * set of relations to be truncated.
125  */
126  struct
127  {
129  bool cascade;
133 
134  /* Message with arbitrary data. */
135  struct
136  {
137  char *prefix;
139  char *message;
140  } msg;
141 
142  /* New snapshot, set when action == *_INTERNAL_SNAPSHOT */
144 
145  /*
146  * New command id for existing snapshot in a catalog changing tx. Set
147  * when action == *_INTERNAL_COMMAND_ID.
148  */
150 
151  /*
152  * New cid mapping for catalog changing transaction, set when action
153  * == *_INTERNAL_TUPLECID.
154  */
155  struct
156  {
163 
164  /* Invalidation. */
165  struct
166  {
167  uint32 ninvalidations; /* Number of messages */
168  SharedInvalidationMessage *invalidations; /* invalidation message */
169  } inval;
170  } data;
171 
172  /*
173  * While in use this is how a change is linked into a transactions,
174  * otherwise it's the preallocated list.
175  */
178 
179 /* ReorderBufferTXN txn_flags */
180 #define RBTXN_HAS_CATALOG_CHANGES 0x0001
181 #define RBTXN_IS_SUBXACT 0x0002
182 #define RBTXN_IS_SERIALIZED 0x0004
183 #define RBTXN_IS_SERIALIZED_CLEAR 0x0008
184 #define RBTXN_IS_STREAMED 0x0010
185 #define RBTXN_HAS_PARTIAL_CHANGE 0x0020
186 #define RBTXN_PREPARE 0x0040
187 #define RBTXN_SKIPPED_PREPARE 0x0080
188 #define RBTXN_HAS_STREAMABLE_CHANGE 0x0100
189 
190 /* Does the transaction have catalog changes? */
191 #define rbtxn_has_catalog_changes(txn) \
192 ( \
193  ((txn)->txn_flags & RBTXN_HAS_CATALOG_CHANGES) != 0 \
194 )
195 
196 /* Is the transaction known as a subxact? */
197 #define rbtxn_is_known_subxact(txn) \
198 ( \
199  ((txn)->txn_flags & RBTXN_IS_SUBXACT) != 0 \
200 )
201 
202 /* Has this transaction been spilled to disk? */
203 #define rbtxn_is_serialized(txn) \
204 ( \
205  ((txn)->txn_flags & RBTXN_IS_SERIALIZED) != 0 \
206 )
207 
208 /* Has this transaction ever been spilled to disk? */
209 #define rbtxn_is_serialized_clear(txn) \
210 ( \
211  ((txn)->txn_flags & RBTXN_IS_SERIALIZED_CLEAR) != 0 \
212 )
213 
214 /* Has this transaction contains partial changes? */
215 #define rbtxn_has_partial_change(txn) \
216 ( \
217  ((txn)->txn_flags & RBTXN_HAS_PARTIAL_CHANGE) != 0 \
218 )
219 
220 /* Does this transaction contain streamable changes? */
221 #define rbtxn_has_streamable_change(txn) \
222 ( \
223  ((txn)->txn_flags & RBTXN_HAS_STREAMABLE_CHANGE) != 0 \
224 )
225 
226 /*
227  * Has this transaction been streamed to downstream?
228  *
229  * (It's not possible to deduce this from nentries and nentries_mem for
230  * various reasons. For example, all changes may be in subtransactions in
231  * which case we'd have nentries==0 for the toplevel one, which would say
232  * nothing about the streaming. So we maintain this flag, but only for the
233  * toplevel transaction.)
234  */
235 #define rbtxn_is_streamed(txn) \
236 ( \
237  ((txn)->txn_flags & RBTXN_IS_STREAMED) != 0 \
238 )
239 
240 /* Has this transaction been prepared? */
241 #define rbtxn_prepared(txn) \
242 ( \
243  ((txn)->txn_flags & RBTXN_PREPARE) != 0 \
244 )
245 
246 /* prepare for this transaction skipped? */
247 #define rbtxn_skip_prepared(txn) \
248 ( \
249  ((txn)->txn_flags & RBTXN_SKIPPED_PREPARE) != 0 \
250 )
251 
252 /* Is this a top-level transaction? */
253 #define rbtxn_is_toptxn(txn) \
254 ( \
255  (txn)->toptxn == NULL \
256 )
257 
258 /* Is this a subtransaction? */
259 #define rbtxn_is_subtxn(txn) \
260 ( \
261  (txn)->toptxn != NULL \
262 )
263 
264 /* Get the top-level transaction of this (sub)transaction. */
265 #define rbtxn_get_toptxn(txn) \
266 ( \
267  rbtxn_is_subtxn(txn) ? (txn)->toptxn : (txn) \
268 )
269 
270 typedef struct ReorderBufferTXN
271 {
272  /* See above */
274 
275  /* The transaction's transaction id, can be a toplevel or sub xid. */
277 
278  /* Xid of top-level transaction, if known */
280 
281  /*
282  * Global transaction id required for identification of prepared
283  * transactions.
284  */
285  char *gid;
286 
287  /*
288  * LSN of the first data carrying, WAL record with knowledge about this
289  * xid. This is allowed to *not* be first record adorned with this xid, if
290  * the previous records aren't relevant for logical decoding.
291  */
293 
294  /* ----
295  * LSN of the record that lead to this xact to be prepared or committed or
296  * aborted. This can be a
297  * * plain commit record
298  * * plain commit record, of a parent transaction
299  * * prepared transaction
300  * * prepared transaction commit
301  * * plain abort record
302  * * prepared transaction abort
303  *
304  * This can also become set to earlier values than transaction end when
305  * a transaction is spilled to disk; specifically it's set to the LSN of
306  * the latest change written to disk so far.
307  * ----
308  */
310 
311  /*
312  * LSN pointing to the end of the commit record + 1.
313  */
315 
316  /* Toplevel transaction for this subxact (NULL for top-level). */
318 
319  /*
320  * LSN of the last lsn at which snapshot information reside, so we can
321  * restart decoding from there and fully recover this transaction from
322  * WAL.
323  */
325 
326  /* origin of the change that caused this transaction */
329 
330  /*
331  * Commit or Prepare time, only known when we read the actual commit or
332  * prepare record.
333  */
334  union
335  {
340 
341  /*
342  * The base snapshot is used to decode all changes until either this
343  * transaction modifies the catalog, or another catalog-modifying
344  * transaction commits.
345  */
348  dlist_node base_snapshot_node; /* link in txns_by_base_snapshot_lsn */
349 
350  /*
351  * Snapshot/CID from the previous streaming run. Only valid for already
352  * streamed transactions (NULL/InvalidCommandId otherwise).
353  */
356 
357  /*
358  * How many ReorderBufferChange's do we have in this txn.
359  *
360  * Changes in subtransactions are *not* included but tracked separately.
361  */
362  uint64 nentries;
363 
364  /*
365  * How many of the above entries are stored in memory in contrast to being
366  * spilled to disk.
367  */
368  uint64 nentries_mem;
369 
370  /*
371  * List of ReorderBufferChange structs, including new Snapshots, new
372  * CommandIds and command invalidation messages.
373  */
375 
376  /*
377  * List of (relation, ctid) => (cmin, cmax) mappings for catalog tuples.
378  * Those are always assigned to the toplevel transaction. (Keep track of
379  * #entries to create a hash of the right size)
380  */
382  uint64 ntuplecids;
383 
384  /*
385  * On-demand built hash for looking up the above values.
386  */
388 
389  /*
390  * Hash containing (potentially partial) toast entries. NULL if no toast
391  * tuples have been found for the current change.
392  */
394 
395  /*
396  * non-hierarchical list of subtransactions that are *not* aborted. Only
397  * used in toplevel transactions.
398  */
401 
402  /*
403  * Stored cache invalidations. This is not a linked list because we get
404  * all the invalidations at once.
405  */
408 
409  /* ---
410  * Position in one of three lists:
411  * * list of subtransactions if we are *known* to be subxact
412  * * list of toplevel xacts (can be an as-yet unknown subxact)
413  * * list of preallocated ReorderBufferTXNs (if unused)
414  * ---
415  */
417 
418  /*
419  * A node in the list of catalog modifying transactions
420  */
422 
423  /*
424  * Size of this transaction (changes currently in memory, in bytes).
425  */
427 
428  /* Size of top-transaction including sub-transactions. */
430 
431  /* If we have detected concurrent abort then ignore future changes. */
433 
434  /*
435  * Private data pointer of the output plugin.
436  */
439 
440 /* so we can define the callbacks used inside struct ReorderBuffer itself */
441 typedef struct ReorderBuffer ReorderBuffer;
442 
443 /* change callback signature */
445  ReorderBufferTXN *txn,
446  Relation relation,
447  ReorderBufferChange *change);
448 
449 /* truncate callback signature */
451  ReorderBufferTXN *txn,
452  int nrelations,
453  Relation relations[],
454  ReorderBufferChange *change);
455 
456 /* begin callback signature */
457 typedef void (*ReorderBufferBeginCB) (ReorderBuffer *rb,
458  ReorderBufferTXN *txn);
459 
460 /* commit callback signature */
462  ReorderBufferTXN *txn,
463  XLogRecPtr commit_lsn);
464 
465 /* message callback signature */
467  ReorderBufferTXN *txn,
468  XLogRecPtr message_lsn,
469  bool transactional,
470  const char *prefix, Size sz,
471  const char *message);
472 
473 /* begin prepare callback signature */
475  ReorderBufferTXN *txn);
476 
477 /* prepare callback signature */
479  ReorderBufferTXN *txn,
480  XLogRecPtr prepare_lsn);
481 
482 /* commit prepared callback signature */
484  ReorderBufferTXN *txn,
485  XLogRecPtr commit_lsn);
486 
487 /* rollback prepared callback signature */
489  ReorderBufferTXN *txn,
490  XLogRecPtr prepare_end_lsn,
491  TimestampTz prepare_time);
492 
493 /* start streaming transaction callback signature */
494 typedef void (*ReorderBufferStreamStartCB) (
495  ReorderBuffer *rb,
496  ReorderBufferTXN *txn,
497  XLogRecPtr first_lsn);
498 
499 /* stop streaming transaction callback signature */
500 typedef void (*ReorderBufferStreamStopCB) (
501  ReorderBuffer *rb,
502  ReorderBufferTXN *txn,
503  XLogRecPtr last_lsn);
504 
505 /* discard streamed transaction callback signature */
506 typedef void (*ReorderBufferStreamAbortCB) (
507  ReorderBuffer *rb,
508  ReorderBufferTXN *txn,
509  XLogRecPtr abort_lsn);
510 
511 /* prepare streamed transaction callback signature */
513  ReorderBuffer *rb,
514  ReorderBufferTXN *txn,
515  XLogRecPtr prepare_lsn);
516 
517 /* commit streamed transaction callback signature */
519  ReorderBuffer *rb,
520  ReorderBufferTXN *txn,
521  XLogRecPtr commit_lsn);
522 
523 /* stream change callback signature */
525  ReorderBuffer *rb,
526  ReorderBufferTXN *txn,
527  Relation relation,
528  ReorderBufferChange *change);
529 
530 /* stream message callback signature */
532  ReorderBuffer *rb,
533  ReorderBufferTXN *txn,
534  XLogRecPtr message_lsn,
535  bool transactional,
536  const char *prefix, Size sz,
537  const char *message);
538 
539 /* stream truncate callback signature */
541  ReorderBuffer *rb,
542  ReorderBufferTXN *txn,
543  int nrelations,
544  Relation relations[],
545  ReorderBufferChange *change);
546 
547 /* update progress txn callback signature */
549  ReorderBuffer *rb,
550  ReorderBufferTXN *txn,
551  XLogRecPtr lsn);
552 
554 {
555  /*
556  * xid => ReorderBufferTXN lookup table
557  */
559 
560  /*
561  * Transactions that could be a toplevel xact, ordered by LSN of the first
562  * record bearing that xid.
563  */
565 
566  /*
567  * Transactions and subtransactions that have a base snapshot, ordered by
568  * LSN of the record which caused us to first obtain the base snapshot.
569  * This is not the same as toplevel_by_lsn, because we only set the base
570  * snapshot on the first logical-decoding-relevant record (eg. heap
571  * writes), whereas the initial LSN could be set by other operations.
572  */
574 
575  /*
576  * Transactions and subtransactions that have modified system catalogs.
577  */
579 
580  /*
581  * one-entry sized cache for by_txn. Very frequently the same txn gets
582  * looked up over and over again.
583  */
586 
587  /*
588  * Callbacks to be called when a transactions commits.
589  */
595 
596  /*
597  * Callbacks to be called when streaming a transaction at prepare time.
598  */
603 
604  /*
605  * Callbacks to be called when streaming a transaction.
606  */
615 
616  /*
617  * Callback to be called when updating progress during sending data of a
618  * transaction (and its subtransactions) to the output plugin.
619  */
621 
622  /*
623  * Pointer that will be passed untouched to the callbacks.
624  */
626 
627  /*
628  * Saved output plugin option
629  */
631 
632  /*
633  * Private memory context.
634  */
636 
637  /*
638  * Memory contexts for specific types objects
639  */
643 
645 
646  /* buffer for disk<->memory conversions */
647  char *outbuf;
649 
650  /* memory accounting */
652 
653  /*
654  * Statistics about transactions spilled to disk.
655  *
656  * A single transaction may be spilled repeatedly, which is why we keep
657  * two different counters. For spilling, the transaction counter includes
658  * both toplevel transactions and subtransactions.
659  */
660  int64 spillTxns; /* number of transactions spilled to disk */
661  int64 spillCount; /* spill-to-disk invocation counter */
662  int64 spillBytes; /* amount of data spilled to disk */
663 
664  /* Statistics about transactions streamed to the decoding output plugin */
665  int64 streamTxns; /* number of transactions streamed */
666  int64 streamCount; /* streaming invocation counter */
667  int64 streamBytes; /* amount of data decoded */
668 
669  /*
670  * Statistics about all the transactions sent to the decoding output
671  * plugin
672  */
673  int64 totalTxns; /* total number of transactions sent */
674  int64 totalBytes; /* total amount of data decoded */
675 };
676 
677 
679 extern void ReorderBufferFree(ReorderBuffer *rb);
680 
682  Size tuple_len);
684  ReorderBufferTupleBuf *tuple);
687  ReorderBufferChange *change, bool upd_mem);
688 
689 extern Oid *ReorderBufferGetRelids(ReorderBuffer *rb, int nrelids);
690 extern void ReorderBufferReturnRelids(ReorderBuffer *rb, Oid *relids);
691 
693  XLogRecPtr lsn, ReorderBufferChange *change,
694  bool toast_insert);
696  Snapshot snap, XLogRecPtr lsn,
697  bool transactional, const char *prefix,
698  Size message_size, const char *message);
699 extern void ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
700  XLogRecPtr commit_lsn, XLogRecPtr end_lsn,
701  TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn);
703  XLogRecPtr commit_lsn, XLogRecPtr end_lsn,
704  XLogRecPtr two_phase_at,
705  TimestampTz commit_time,
706  RepOriginId origin_id, XLogRecPtr origin_lsn,
707  char *gid, bool is_commit);
709  TransactionId subxid, XLogRecPtr lsn);
711  TransactionId subxid, XLogRecPtr commit_lsn,
712  XLogRecPtr end_lsn);
713 extern void ReorderBufferAbort(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn,
714  TimestampTz abort_time);
715 extern void ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid);
716 extern void ReorderBufferForget(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn);
718 
720  XLogRecPtr lsn, Snapshot snap);
722  XLogRecPtr lsn, Snapshot snap);
724  XLogRecPtr lsn, CommandId cid);
726  XLogRecPtr lsn, RelFileLocator locator,
727  ItemPointerData tid,
728  CommandId cmin, CommandId cmax, CommandId combocid);
730  Size nmsgs, SharedInvalidationMessage *msgs);
731 extern void ReorderBufferImmediateInvalidation(ReorderBuffer *rb, uint32 ninvalidations,
732  SharedInvalidationMessage *invalidations);
734 
738 
740  XLogRecPtr prepare_lsn, XLogRecPtr end_lsn,
741  TimestampTz prepare_time,
742  RepOriginId origin_id, XLogRecPtr origin_lsn);
744 extern void ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid, char *gid);
748 
750 
751 extern void StartupReorderBuffer(void);
752 
753 #endif
unsigned int uint32
Definition: c.h:495
#define PGDLLIMPORT
Definition: c.h:1326
uint32 bits32
Definition: c.h:504
uint32 CommandId
Definition: c.h:655
uint32 TransactionId
Definition: c.h:641
size_t Size
Definition: c.h:594
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)
void ReorderBufferReturnTupleBuf(ReorderBuffer *rb, ReorderBufferTupleBuf *tuple)
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)
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:26
@ DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE
Definition: reorderbuffer.h:28
@ DEBUG_LOGICAL_REP_STREAMING_BUFFERED
Definition: reorderbuffer.h:27
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)
struct ReorderBufferTupleBuf ReorderBufferTupleBuf
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 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)
ReorderBufferTupleBuf * ReorderBufferGetTupleBuf(ReorderBuffer *rb, Size tuple_len)
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:64
@ REORDER_BUFFER_CHANGE_INVALIDATION
Definition: reorderbuffer.h:69
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM
Definition: reorderbuffer.h:74
@ REORDER_BUFFER_CHANGE_INSERT
Definition: reorderbuffer.h:65
@ REORDER_BUFFER_CHANGE_MESSAGE
Definition: reorderbuffer.h:68
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT
Definition: reorderbuffer.h:75
@ REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID
Definition: reorderbuffer.h:71
@ REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID
Definition: reorderbuffer.h:72
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT
Definition: reorderbuffer.h:73
@ REORDER_BUFFER_CHANGE_TRUNCATE
Definition: reorderbuffer.h:76
@ REORDER_BUFFER_CHANGE_DELETE
Definition: reorderbuffer.h:67
@ REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT
Definition: reorderbuffer.h:70
@ REORDER_BUFFER_CHANGE_UPDATE
Definition: reorderbuffer.h:66
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
struct ReorderBufferChange::@100::@101 tp
ReorderBufferTupleBuf * newtuple
ReorderBufferChangeType action
Definition: reorderbuffer.h:94
RelFileLocator rlocator
ItemPointerData tid
struct ReorderBufferTXN * txn
Definition: reorderbuffer.h:97
struct ReorderBufferChange::@100::@102 truncate
RelFileLocator locator
RepOriginId origin_id
Definition: reorderbuffer.h:99
union ReorderBufferChange::@100 data
struct ReorderBufferChange::@100::@105 inval
struct ReorderBufferChange::@100::@103 msg
struct ReorderBufferChange::@100::@104 tuplecid
ReorderBufferTupleBuf * oldtuple
SharedInvalidationMessage * invalidations
CommandId command_id
XLogRecPtr restart_decoding_lsn
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::@106 xact_time
dlist_head subtxns
HeapTupleData tuple
Definition: reorderbuffer.h:38
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
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