Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)

From: "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)
Date: 2022-08-23 07:58:03
Message-ID: 61a95a06-cf88-cd15-0412-172717943e18@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 8/22/22 7:36 PM, Andres Freund wrote:
> On 2022-08-22 18:39:07 +0200, Drouvot, Bertrand wrote:
>> Please find attached a patch proposal to fix it.
> Perhaps a better fix would be to move the pgstat_create_relation() from
> heap_create_with_catalog() into heap_create()? Although I guess it's a bit
> pointless to deduplicate given that you're going to split it up again...

Thanks for looking at it!

Agree it's better to move it to heap_create(): it's done in the new
version attached.

We'll see later on if it needs to be duplicated for the table/index
split work.

>> It does contain additional calls to pgstat_create_relation() and
>> pgstat_drop_relation() as well as additional TAP tests.
> Would be good to add a test for CREATE INDEX / DROP INDEX / REINDEX
> CONCURRENTLY as well.
>
> Might be worth adding a test to stats.sql or stats.spec in the main regression
> tests. Perhaps that's best where the aforementioned things should be tested?

Yeah that sounds better, I'm also adding more tests around table
creation while at it.

I ended up adding the new tests in stats.sql.

>
>> @@ -2349,6 +2354,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
>> CatalogTupleDelete(indexRelation, &tuple->t_self);
>>
>> ReleaseSysCache(tuple);
>> +
>> table_close(indexRelation, RowExclusiveLock);
>>
>> /*
> Assume this was just an accident?

Oops, thanks!

New version attached.

Regards,

--
Bertrand Drouvot
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v1-0002-pgstat_drop_relation-for-indexes.patch text/plain 9.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2022-08-23 08:21:59 Re: SQL/JSON features for v15
Previous Message Amit Langote 2022-08-23 07:48:44 Re: SQL/JSON features for v15