Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ac46de5

Browse files
committed
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.
1 parent a61daa1 commit ac46de5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/backend/postmaster/pgstat.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ pgstat_report_stat(bool force)
753753

754754
/* Don't expend a clock check if nothing to do */
755755
if ((pgStatTabList == NULL || pgStatTabList->tsa_used == 0) &&
756-
!have_function_stats && !force)
756+
pgStatXactCommit == 0 && pgStatXactRollback == 0 &&
757+
!have_function_stats)
757758
return;
758759

759760
/*
@@ -817,11 +818,11 @@ pgstat_report_stat(bool force)
817818
}
818819

819820
/*
820-
* Send partial messages. If force is true, make sure that any pending
821-
* xact commit/abort gets counted, even if no table stats to send.
821+
* Send partial messages. Make sure that any pending xact commit/abort
822+
* gets counted, even if there are no table stats to send.
822823
*/
823824
if (regular_msg.m_nentries > 0 ||
824-
(force && (pgStatXactCommit > 0 || pgStatXactRollback > 0)))
825+
pgStatXactCommit > 0 || pgStatXactRollback > 0)
825826
pgstat_send_tabstat(&regular_msg);
826827
if (shared_msg.m_nentries > 0)
827828
pgstat_send_tabstat(&shared_msg);

0 commit comments

Comments
 (0)