diff options
author | Amit Kapila <akapila@postgresql.org> | 2019-04-10 08:36:42 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2019-04-10 08:36:42 +0530 |
commit | 036f7d3782e53573d2080e7d967fff375bc516b5 (patch) | |
tree | cafc7fb1a8705c0d93ab904a1625dc05dda7de30 /src/backend/access/transam | |
parent | 47b6362b58e03aa2e1f55550539f79321375693b (diff) | |
download | postgresql-036f7d3782e53573d2080e7d967fff375bc516b5.tar.gz postgresql-036f7d3782e53573d2080e7d967fff375bc516b5.zip |
Avoid counting transaction stats for parallel worker cooperating
transaction.
The transaction that is initiated by the parallel worker to cooperate
with the actual transaction started by the main backend to complete the
query execution should not be counted as a separate transaction. The
other internal transactions started and committed by the parallel worker
are still counted as separate transactions as we that is what we do in
other places like autovacuum.
This will partially fix the bloat in transaction stats due to additional
transactions performed by parallel workers. For a complete fix, we need to
decide how we want to show all the transactions that are started internally
for various operations and that is a matter of separate patch.
Reported-by: Haribabu Kommi
Author: Haribabu Kommi
Reviewed-by: Amit Kapila, Jamison Kirk and Rahila Syed
Backpatch-through: 9.6
Discussion: https://postgr.es/m/CAJrrPGc9=jKXuScvNyQ+VNhO0FZk7LLAShAJRyZjnedd2D61EQ@mail.gmail.com
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r-- | src/backend/access/transam/twophase.c | 2 | ||||
-rw-r--r-- | src/backend/access/transam/xact.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 349d94a5e67..2af0832e500 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -1574,7 +1574,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit) PredicateLockTwoPhaseFinish(xid, isCommit); /* Count the prepared xact as committed or aborted */ - AtEOXact_PgStat(isCommit); + AtEOXact_PgStat(isCommit, false); /* * And now we can clean up any files we may have left. diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 4cf5ffeedb4..c97862e7dc3 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -2164,7 +2164,7 @@ CommitTransaction(void) AtEOXact_Files(true); AtEOXact_ComboCid(); AtEOXact_HashTables(true); - AtEOXact_PgStat(true); + AtEOXact_PgStat(true, is_parallel_worker); AtEOXact_Snapshot(true, false); AtEOXact_ApplyLauncher(true); pgstat_report_xact_timestamp(0); @@ -2656,7 +2656,7 @@ AbortTransaction(void) AtEOXact_Files(false); AtEOXact_ComboCid(); AtEOXact_HashTables(false); - AtEOXact_PgStat(false); + AtEOXact_PgStat(false, is_parallel_worker); AtEOXact_ApplyLauncher(false); pgstat_report_xact_timestamp(0); } |