Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit205f466

Browse files
author
Amit Kapila
committed
Fix the computation of slot stats for 'total_bytes'.
Previously, we were using the size of all the changes present inReorderBuffer to compute total_bytes after decoding a transaction and thatcan lead to counting some of the transactions' changes more than once. Fixit by using the size of the changes decoded for a transaction to compute'total_bytes'.Author: Sawada MasahikoReviewed-by: Vignesh C, Amit KapilaDiscussion:https://postgr.es/m/20210319185247.ldebgpdaxsowiflw@alap3.anarazel.de
1 parenteb08605 commit205f466

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,10 +1366,11 @@ ReorderBufferIterTXNNext(ReorderBuffer *rb, ReorderBufferIterTXNState *state)
13661366
dlist_push_tail(&state->old_change,&change->node);
13671367

13681368
/*
1369-
* Update the total bytes processed before releasing the current set
1370-
* of changes and restoring the new set of changes.
1369+
* Update the total bytes processed by the txn for which we are
1370+
* releasing the current set of changes and restoring the new set of
1371+
* changes.
13711372
*/
1372-
rb->totalBytes+=rb->size;
1373+
rb->totalBytes+=entry->txn->size;
13731374
if (ReorderBufferRestoreChanges(rb,entry->txn,&entry->file,
13741375
&state->entries[off].segno))
13751376
{
@@ -2371,9 +2372,9 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
23712372
iterstate=NULL;
23722373

23732374
/*
2374-
* Update total transaction count and totaltransactionbytes
2375-
*processed. Ensure to not count the streamed transaction multiple
2376-
* times.
2375+
* Update total transaction count and total bytes processed by the
2376+
*transaction and its subtransactions. Ensure to not count the
2377+
*streamed transaction multipletimes.
23772378
*
23782379
* Note that the statistics computation has to be done after
23792380
* ReorderBufferIterTXNFinish as it releases the serialized change
@@ -2382,7 +2383,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
23822383
if (!rbtxn_is_streamed(txn))
23832384
rb->totalTxns++;
23842385

2385-
rb->totalBytes+=rb->size;
2386+
rb->totalBytes+=txn->total_size;
23862387

23872388
/*
23882389
* Done with current changes, send the last message for this set of
@@ -3073,7 +3074,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
30733074
{
30743075
Sizesz;
30753076
ReorderBufferTXN*txn;
3076-
ReorderBufferTXN*toptxn=NULL;
3077+
ReorderBufferTXN*toptxn;
30773078

30783079
Assert(change->txn);
30793080

@@ -3087,14 +3088,14 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
30873088

30883089
txn=change->txn;
30893090

3090-
/* If streaming supported, update the total size in top level as well. */
3091-
if (ReorderBufferCanStream(rb))
3092-
{
3093-
if (txn->toptxn!=NULL)
3094-
toptxn=txn->toptxn;
3095-
else
3096-
toptxn=txn;
3097-
}
3091+
/*
3092+
* Update the total size in top level as well. This is later used to
3093+
* compute the decoding stats.
3094+
*/
3095+
if (txn->toptxn!=NULL)
3096+
toptxn=txn->toptxn;
3097+
else
3098+
toptxn=txn;
30983099

30993100
sz=ReorderBufferChangeSize(change);
31003101

@@ -3104,8 +3105,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
31043105
rb->size+=sz;
31053106

31063107
/* Update the total size in the top transaction. */
3107-
if (toptxn)
3108-
toptxn->total_size+=sz;
3108+
toptxn->total_size+=sz;
31093109
}
31103110
else
31113111
{
@@ -3114,8 +3114,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
31143114
rb->size-=sz;
31153115

31163116
/* Update the total size in the top transaction. */
3117-
if (toptxn)
3118-
toptxn->total_size-=sz;
3117+
toptxn->total_size-=sz;
31193118
}
31203119

31213120
Assert(txn->size <=rb->size);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp