Stats sender and 2pc minor problem

From: Stas Kelvich <s(dot)kelvich(at)postgrespro(dot)ru>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Stats sender and 2pc minor problem
Date: 2016-10-13 12:36:59
Message-ID: EB57BF68-C06D-4737-BDDC-4BA778F4E62B@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

Statistics sender logic during usual commit and two-phase commit do not strictly matches each other and that leads to
delta_live_tuples added to n_live_tup in case of truncate in two phase commit.

That can be see in following example:

CREATE TABLE trunc_stats_test5(id serial);
INSERT INTO trunc_stats_test5 DEFAULT VALUES;
INSERT INTO trunc_stats_test5 DEFAULT VALUES;
INSERT INTO trunc_stats_test5 DEFAULT VALUES;
BEGIN;
TRUNCATE trunc_stats_test5;
PREPARE TRANSACTION 'twophase_stats';
COMMIT PREPARED 'twophase_stats';

After that pg_stat_user_tables will have n_live_tup = 3 instead of 0.

Fix along with test is attached.

Attachment Content-Type Size
2pc-stats.patch application/octet-stream 4.0 KB
unknown_filename text/plain 94 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2016-10-13 12:45:35 pg_dump: Simplify internal archive version handling
Previous Message Craig Ringer 2016-10-13 12:32:31 Re: Add PGDLLEXPORT to PG_FUNCTION_INFO_V1