aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/replication/logical/reorderbuffer.c7
-rw-r--r--src/include/replication/reorderbuffer.h9
2 files changed, 13 insertions, 3 deletions
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 524946a2a27..8f4f7f842bc 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -893,7 +893,7 @@ ReorderBufferIterTXNInit(ReorderBuffer *rb, ReorderBufferTXN *txn)
{
ReorderBufferChange *cur_change;
- if (txn->nentries != txn->nentries_mem)
+ if (txn->serialized)
{
/* serialize remaining changes */
ReorderBufferSerializeTXN(rb, txn);
@@ -922,7 +922,7 @@ ReorderBufferIterTXNInit(ReorderBuffer *rb, ReorderBufferTXN *txn)
{
ReorderBufferChange *cur_change;
- if (cur_txn->nentries != cur_txn->nentries_mem)
+ if (cur_txn->serialized)
{
/* serialize remaining changes */
ReorderBufferSerializeTXN(rb, cur_txn);
@@ -1142,7 +1142,7 @@ ReorderBufferCleanupTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Assert(found);
/* remove entries spilled to disk */
- if (txn->nentries != txn->nentries_mem)
+ if (txn->serialized)
ReorderBufferRestoreCleanup(rb, txn);
/* deallocate */
@@ -2124,6 +2124,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Assert(spilled == txn->nentries_mem);
Assert(dlist_is_empty(&txn->changes));
txn->nentries_mem = 0;
+ txn->serialized = true;
if (fd != -1)
CloseTransientFile(fd);
diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h
index 17e47b385b7..8d8d418e8e3 100644
--- a/src/include/replication/reorderbuffer.h
+++ b/src/include/replication/reorderbuffer.h
@@ -213,6 +213,15 @@ typedef struct ReorderBufferTXN
uint64 nentries_mem;
/*
+ * Has this transaction been spilled to disk? It's not always possible to
+ * deduce that fact by comparing nentries with nentries_mem, because
+ * e.g. subtransactions of a large transaction might get serialized
+ * together with the parent - if they're restored to memory they'd have
+ * nentries_mem == nentries.
+ */
+ bool serialized;
+
+ /*
* List of ReorderBufferChange structs, including new Snapshots and new
* CommandIds
*/