From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pgstat: Fix transactional stats dropping for indexes
Date: Fri, 23 Sep 2022 20:43:20 +0000
Message-ID: <E1obpW3-001hn8-Ia@gemulon.postgresql.org> (raw)
pgstat: Fix transactional stats dropping for indexes
Because index creation does not go through heap_create_with_catalog() we
didn't call pgstat_create_relation(), leading to index stats of a newly
created realtion not getting dropped during rollback. To fix, move the
pgstat_create_relation() to heap_create(), which indexes do use.
Similarly, because dropping an index does not go through
heap_drop_with_catalog(), we didn't drop index stats when the transaction
dropping an index committed. Here there's no convenient common path for
indexes and relations, so index_drop() now calls pgstat_drop_relation().
Add tests for transactional index stats handling.
Author: "Drouvot, Bertrand" <bdrouvot@amazon.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/51bbf286-2b4a-8998-bd12-eaae4b765d99@amazon.com
Backpatch: 15-, like 8b1dccd37c71, which introduced the bug
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/43e496e242984320efcf42c51c1e2b379aa03344
Modified Files
--------------
src/backend/catalog/heap.c | 6 +-
src/backend/catalog/index.c | 3 +
src/test/regress/expected/stats.out | 109 +++++++++++++++++++++++++++++++++++-
src/test/regress/sql/stats.sql | 50 ++++++++++++++++-
4 files changed, 161 insertions(+), 7 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de
Subject: Re: pgsql: pgstat: Fix transactional stats dropping for indexes
In-Reply-To: <E1obpW3-001hn8-Ia@gemulon.postgresql.org>
References: <E1obpW3-001hn8-Ia@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox