aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Grittner <kgrittn@postgresql.org>2014-07-02 15:20:30 -0500
committerKevin Grittner <kgrittn@postgresql.org>2014-07-02 15:20:30 -0500
commitac46de56eab9bb93c23c7f34070f3a16e7e76743 (patch)
tree35457e59e3bdf64135dfc24d4751372926294442
parenta61daa14d56867e90dc011bbba52ef771cea6770 (diff)
downloadpostgresql-ac46de56eab9bb93c23c7f34070f3a16e7e76743.tar.gz
postgresql-ac46de56eab9bb93c23c7f34070f3a16e7e76743.zip
Smooth reporting of commit/rollback statistics.
If a connection committed or rolled back any transactions within a PGSTAT_STAT_INTERVAL pacing interval without accessing any tables, the reporting of those statistics would be held up until the connection closed or until it ended a PGSTAT_STAT_INTERVAL interval in which it had accessed a table. This could result in under- reporting of transactions for an extended period, followed by a spike in reported transactions. While this is arguably a bug, the impact is minimal, primarily affecting, and being affected by, monitoring software. It might cause more confusion than benefit to change the existing behavior in released stable branches, so apply only to master and the 9.4 beta. Gurjeet Singh, with review and editing by Kevin Grittner, incorporating suggested changes from Abhijit Menon-Sen and Tom Lane.
-rw-r--r--src/backend/postmaster/pgstat.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 3ab1428f7c7..c7f41a50673 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -753,7 +753,8 @@ pgstat_report_stat(bool force)
/* Don't expend a clock check if nothing to do */
if ((pgStatTabList == NULL || pgStatTabList->tsa_used == 0) &&
- !have_function_stats && !force)
+ pgStatXactCommit == 0 && pgStatXactRollback == 0 &&
+ !have_function_stats)
return;
/*
@@ -817,11 +818,11 @@ pgstat_report_stat(bool force)
}
/*
- * Send partial messages. If force is true, make sure that any pending
- * xact commit/abort gets counted, even if no table stats to send.
+ * Send partial messages. Make sure that any pending xact commit/abort
+ * gets counted, even if there are no table stats to send.
*/
if (regular_msg.m_nentries > 0 ||
- (force && (pgStatXactCommit > 0 || pgStatXactRollback > 0)))
+ pgStatXactCommit > 0 || pgStatXactRollback > 0)
pgstat_send_tabstat(&regular_msg);
if (shared_msg.m_nentries > 0)
pgstat_send_tabstat(&shared_msg);