Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back) - Mailing list pgsql-hackers

From Drouvot, Bertrand
Subject Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)
Date
Msg-id 61a95a06-cf88-cd15-0412-172717943e18@amazon.com
Whole thread Raw
In response to Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)  (Andres Freund <andres@anarazel.de>)
Responses Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)
List 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

pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: SQL/JSON features for v15
Next
From: Amit Langote
Date:
Subject: Re: SQL/JSON features for v15