Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81e82a2

Browse files
committed
Fix handling of pgstat counters for TRUNCATE in a prepared transaction.
pgstat_twophase_postcommit is supposed to duplicate the math inAtEOXact_PgStat, but it had missed out the bit about clearingt_delta_live_tuples/t_delta_dead_tuples for a TRUNCATE.It's harder than you might think to replicate the issue here, becausethose counters would only be nonzero when a previous transaction inthe 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 commitd42358e. I've not added a regressiontest for this; we tried to add one ind42358e, and had to revert itbecause it was too timing-sensitive for the buildfarm.Back-patch to 9.5 whered42358e came in.Stas KelvichDiscussion: <EB57BF68-C06D-4737-BDDC-4BA778F4E62B@postgrespro.ru>
1 parentb1ee762 commit81e82a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,12 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info,
22262226
pgstat_info->t_counts.t_tuples_updated+=rec->tuples_updated;
22272227
pgstat_info->t_counts.t_tuples_deleted+=rec->tuples_deleted;
22282228
pgstat_info->t_counts.t_truncated=rec->t_truncated;
2229-
2229+
if (rec->t_truncated)
2230+
{
2231+
/* forget live/dead stats seen by backend thus far */
2232+
pgstat_info->t_counts.t_delta_live_tuples=0;
2233+
pgstat_info->t_counts.t_delta_dead_tuples=0;
2234+
}
22302235
pgstat_info->t_counts.t_delta_live_tuples+=
22312236
rec->tuples_inserted-rec->tuples_deleted;
22322237
pgstat_info->t_counts.t_delta_dead_tuples+=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp