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

From Andres Freund
Subject Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)
Date
Msg-id 20220831192657.jqhphpud2mxbzbom@awork3.anarazel.de
Whole thread Raw
In response to Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)  ("Drouvot, Bertrand" <bdrouvot@amazon.com>)
List pgsql-hackers
Hiu,

On 2022-08-25 11:44:34 +0200, Drouvot, Bertrand wrote:
> For REPLSLOT, I agree that we can add one test: I added it in
> contrib/test_decoding/sql/stats.sql. It relies on pg_stat_have_stats() (as
> relying on pg_stat_replication_slots and/or pg_stat_get_replication_slot()
> would not help that much for this test given that the slot has been removed
> from ReplicationSlotCtl)

As Horiguchi-san noted, we can't rely on specific indexes being used. I feel
ok with the current coverage in that area, but if we *really* feel we need to
test it, we'd need to count the number of indexes with slots before dropping
the slot and after the drop.


> +-- pg_stat_have_stats returns true for committed index creation

Maybe another test for an uncommitted index creation would be good too?

Could you try running this test with debug_discard_caches = 1 - it's pretty
easy to write tests in this area that aren't reliable timing wise.


> +CREATE table stats_test_tab1 as select generate_series(1,10) a;
> +CREATE index stats_test_idx1 on stats_test_tab1(a);
> +SELECT oid AS dboid from pg_database where datname = current_database() \gset

Since you introduced this, maybe convert the other instance of this query at
the end of the file as well?


Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Avoid erroring out when unable to remove or parse logical rewrite files to save checkpoint work
Next
From: Andres Freund
Date:
Subject: Re: Avoid erroring out when unable to remove or parse logical rewrite files to save checkpoint work