use_total_size_v3.patch
application/octet-stream
Filename: use_total_size_v3.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
Series: patch v3
| File | + | − |
|---|---|---|
| src/backend/replication/logical/reorderbuffer.c | 16 | 15 |
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c27f7100534..ad0b6b69e76 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -1369,7 +1369,10 @@ ReorderBufferIterTXNNext(ReorderBuffer *rb, ReorderBufferIterTXNState *state)
* Update the total bytes processed before releasing the current set
* of changes and restoring the new set of changes.
*/
- rb->totalBytes += rb->size;
+ if (entry->txn->toptxn)
+ rb->totalBytes += entry->txn->toptxn->total_size;
+ else
+ rb->totalBytes += entry->txn->total_size;
if (ReorderBufferRestoreChanges(rb, entry->txn, &entry->file,
&state->entries[off].segno))
{
@@ -2382,7 +2385,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
if (!rbtxn_is_streamed(txn))
rb->totalTxns++;
- rb->totalBytes += rb->size;
+ rb->totalBytes += txn->total_size;
/*
* Done with current changes, send the last message for this set of
@@ -3073,7 +3076,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
{
Size sz;
ReorderBufferTXN *txn;
- ReorderBufferTXN *toptxn = NULL;
+ ReorderBufferTXN *toptxn;
Assert(change->txn);
@@ -3087,14 +3090,14 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
txn = change->txn;
- /* If streaming supported, update the total size in top level as well. */
- if (ReorderBufferCanStream(rb))
- {
- if (txn->toptxn != NULL)
- toptxn = txn->toptxn;
- else
- toptxn = txn;
- }
+ /*
+ * Update the total size in top level as well. This is later used to
+ * compute the decoding stats.
+ */
+ if (txn->toptxn != NULL)
+ toptxn = txn->toptxn;
+ else
+ toptxn = txn;
sz = ReorderBufferChangeSize(change);
@@ -3104,8 +3107,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
rb->size += sz;
/* Update the total size in the top transaction. */
- if (toptxn)
- toptxn->total_size += sz;
+ toptxn->total_size += sz;
}
else
{
@@ -3114,8 +3116,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
rb->size -= sz;
/* Update the total size in the top transaction. */
- if (toptxn)
- toptxn->total_size -= sz;
+ toptxn->total_size -= sz;
}
Assert(txn->size <= rb->size);