diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-10-13 19:45:58 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-10-13 19:46:06 -0400 |
commit | 03f2bf70a3e6fb57f29e41a86cf8f9a14b082616 (patch) | |
tree | 7843532dc84ce85edb54ddde673a0035de149e6c /src | |
parent | b8850031ccc51401c256203b7dc9029a1160479e (diff) | |
download | postgresql-03f2bf70a3e6fb57f29e41a86cf8f9a14b082616.tar.gz postgresql-03f2bf70a3e6fb57f29e41a86cf8f9a14b082616.zip |
Fix handling of pgstat counters for TRUNCATE in a prepared transaction.
pgstat_twophase_postcommit is supposed to duplicate the math in
AtEOXact_PgStat, but it had missed out the bit about clearing
t_delta_live_tuples/t_delta_dead_tuples for a TRUNCATE.
It's harder than you might think to replicate the issue here, because
those counters would only be nonzero when a previous transaction in
the same backend had added/deleted tuples in the truncated table,
and those counts hadn't been sent to the stats collector yet.
Evident oversight in commit d42358efb. I've not added a regression
test for this; we tried to add one in d42358efb, and had to revert it
because it was too timing-sensitive for the buildfarm.
Back-patch to 9.5 where d42358efb came in.
Stas Kelvich
Discussion: <EB57BF68-C06D-4737-BDDC-4BA778F4E62B@postgrespro.ru>
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/postmaster/pgstat.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 3ff435d6e49..9412bb7e438 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -2221,7 +2221,12 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info, pgstat_info->t_counts.t_tuples_updated += rec->tuples_updated; pgstat_info->t_counts.t_tuples_deleted += rec->tuples_deleted; pgstat_info->t_counts.t_truncated = rec->t_truncated; - + if (rec->t_truncated) + { + /* forget live/dead stats seen by backend thus far */ + pgstat_info->t_counts.t_delta_live_tuples = 0; + pgstat_info->t_counts.t_delta_dead_tuples = 0; + } pgstat_info->t_counts.t_delta_live_tuples += rec->tuples_inserted - rec->tuples_deleted; pgstat_info->t_counts.t_delta_dead_tuples += |