summaryrefslogtreecommitdiff
path: root/src/backend/postmaster
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2019-04-10 08:24:15 +0530
committerAmit Kapila <akapila@postgresql.org>2019-04-10 08:24:15 +0530
commitbdf35744bdf70208fc4d0f4b76f7d4bce3cf326b (patch)
tree9cb868bd578a702726939c010a34fad4188eb0b9 /src/backend/postmaster
parentd614aae02e8f878438716b7fd2642b8240b3f2b3 (diff)
downloadpostgresql-bdf35744bdf70208fc4d0f4b76f7d4bce3cf326b.tar.gz
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/postmaster')
-rw-r--r--src/backend/postmaster/pgstat.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 0355fa65fb..7c0b24a16f 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -2089,18 +2089,22 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
* ----------
*/
void
-AtEOXact_PgStat(bool isCommit)
+AtEOXact_PgStat(bool isCommit, bool parallel)
{
PgStat_SubXactStatus *xact_state;
- /*
- * Count transaction commit or abort. (We use counters, not just bools,
- * in case the reporting message isn't sent right away.)
- */
- if (isCommit)
- pgStatXactCommit++;
- else
- pgStatXactRollback++;
+ /* Don't count parallel worker transaction stats */
+ if (!parallel)
+ {
+ /*
+ * Count transaction commit or abort. (We use counters, not just
+ * bools, in case the reporting message isn't sent right away.)
+ */
+ if (isCommit)
+ pgStatXactCommit++;
+ else
+ pgStatXactRollback++;
+ }
/*
* Transfer transactional insert/update counts into the base tabstat