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