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

Commit7657072

Browse files
author
Amit Kapila
committed
Avoid counting transaction stats for parallel worker cooperating
transaction.The transaction that is initiated by the parallel worker to cooperatewith the actual transaction started by the main backend to complete thequery execution should not be counted as a separate transaction. Theother internal transactions started and committed by the parallel workerare still counted as separate transactions as we that is what we do inother places like autovacuum.This will partially fix the bloat in transaction stats due to additionaltransactions performed by parallel workers. For a complete fix, we need todecide how we want to show all the transactions that are started internallyfor various operations and that is a matter of separate patch.Reported-by: Haribabu KommiAuthor: Haribabu KommiReviewed-by: Amit Kapila, Jamison Kirk and Rahila SyedBackpatch-through: 9.6Discussion:https://postgr.es/m/CAJrrPGc9=jKXuScvNyQ+VNhO0FZk7LLAShAJRyZjnedd2D61EQ@mail.gmail.com
1 parent4c9e545 commit7657072

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

‎src/backend/access/transam/twophase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
15061506
PredicateLockTwoPhaseFinish(xid,isCommit);
15071507

15081508
/* Count the prepared xact as committed or aborted */
1509-
AtEOXact_PgStat(isCommit);
1509+
AtEOXact_PgStat(isCommit, false);
15101510

15111511
/*
15121512
* And now we can clean up any files we may have left.

‎src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ CommitTransaction(void)
21652165
AtEOXact_Files();
21662166
AtEOXact_ComboCid();
21672167
AtEOXact_HashTables(true);
2168-
AtEOXact_PgStat(true);
2168+
AtEOXact_PgStat(true,is_parallel_worker);
21692169
AtEOXact_Snapshot(true, false);
21702170
AtEOXact_ApplyLauncher(true);
21712171
pgstat_report_xact_timestamp(0);
@@ -2657,7 +2657,7 @@ AbortTransaction(void)
26572657
AtEOXact_Files();
26582658
AtEOXact_ComboCid();
26592659
AtEOXact_HashTables(false);
2660-
AtEOXact_PgStat(false);
2660+
AtEOXact_PgStat(false,is_parallel_worker);
26612661
AtEOXact_ApplyLauncher(false);
26622662
pgstat_report_xact_timestamp(0);
26632663
}

‎src/backend/postmaster/pgstat.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,18 +2050,22 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
20502050
* ----------
20512051
*/
20522052
void
2053-
AtEOXact_PgStat(boolisCommit)
2053+
AtEOXact_PgStat(boolisCommit,boolparallel)
20542054
{
20552055
PgStat_SubXactStatus*xact_state;
20562056

2057-
/*
2058-
* Count transaction commit or abort. (We use counters, not just bools,
2059-
* in case the reporting message isn't sent right away.)
2060-
*/
2061-
if (isCommit)
2062-
pgStatXactCommit++;
2063-
else
2064-
pgStatXactRollback++;
2057+
/* Don't count parallel worker transaction stats */
2058+
if (!parallel)
2059+
{
2060+
/*
2061+
* Count transaction commit or abort. (We use counters, not just
2062+
* bools, in case the reporting message isn't sent right away.)
2063+
*/
2064+
if (isCommit)
2065+
pgStatXactCommit++;
2066+
else
2067+
pgStatXactRollback++;
2068+
}
20652069

20662070
/*
20672071
* Transfer transactional insert/update counts into the base tabstat

‎src/include/pgstat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ extern void pgstat_init_function_usage(FunctionCallInfoData *fcinfo,
12991299
externvoidpgstat_end_function_usage(PgStat_FunctionCallUsage*fcu,
13001300
boolfinalize);
13011301

1302-
externvoidAtEOXact_PgStat(boolisCommit);
1302+
externvoidAtEOXact_PgStat(boolisCommit,boolparallel);
13031303
externvoidAtEOSubXact_PgStat(boolisCommit,intnestDepth);
13041304

13051305
externvoidAtPrepare_PgStat(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp