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