pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Drouvot, Bertrand <bdrouvot@amazon.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: andres@anarazel.de
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)
Date: Thu, 1 Sep 2022 07:53:58 +0200
Message-ID: <ee63a22a-e702-fdbc-23ea-9459ec9a01e7@amazon.com> (raw)
In-Reply-To: <20220831.161030.2252231560742777910.horikyota.ntt@gmail.com>
References: <61a95a06-cf88-cd15-0412-172717943e18@amazon.com>
	<20220825.114727.330127256246111733.horikyota.ntt@gmail.com>
	<be4c74ba-e229-126b-6dff-0c879c70c547@amazon.com>
	<20220831.161030.2252231560742777910.horikyota.ntt@gmail.com>

Hi,

On 8/31/22 9:10 AM, Kyotaro Horiguchi wrote:
> Thanks for the searching.
> +-- pg_stat_have_stats returns true for regression_slot_stats1
> +-- Its index is 1 in ReplicationSlotCtl->replication_slots
> +select pg_stat_have_stats('replslot', 0, 1);
>
> This is wrong. The index is actually 0.

Right, thanks for pointing out.

(gdb) p get_replslot_index("regression_slot_stats1")
$1 = 0
(gdb) p get_replslot_index("regression_slot_stats2")
$2 = 1
(gdb) p get_replslot_index("regression_slot_stats3")

$3 = 2

> We cannot know the id
> reliably since we don't expose it at all.

Right.

>   We could slightly increase
> robustness by assuming the range of the id but that is just moving the
> problem to another place. If the test is broken by a change of
> replslot id assignment policy, it would be easily found and fixed.
>
> So is it fine simply fixing the comment with the correct ID?
>
> Or, contrarily we can be more sensitive to the change of ID assignment
> policy by checking all the replication slots.
>
> select count(n) from generate_series(0, 2) as n where pg_stat_have_stats('replslot', 0, n);
>
> The number changes from 3 to 0 across the slots drop.. If any of the
> slots has gone out of the range, the number before the drop decreases.

Thanks for the ideas! I'm coming up with a slightly different one (also 
based on Andre's feedback in [1]) in the upcoming v4.

[1]: 
https://www.postgresql.org/message-id/20220831192657.jqhphpud2mxbzbom%40awork3.anarazel.de

Regards,

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

view thread (12+ messages)  latest in thread

Message-ID: <ee63a22a-e702-fdbc-23ea-9459ec9a01e7@amazon.com>
Permalink:  ../ee63a22a-e702-fdbc-23ea-9459ec9a01e7@amazon.com/
Also on:    postgresql.org/message-id/ee63a22a-e702-fdbc-23ea-9459ec9a01e7@amazon.com

 · 

reply

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-hackers@postgresql.org
  Cc: bdrouvot@amazon.com, horikyota.ntt@gmail.com, andres@anarazel.de
  Subject: Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)
  In-Reply-To: <ee63a22a-e702-fdbc-23ea-9459ec9a01e7@amazon.com>
  References: <61a95a06-cf88-cd15-0412-172717943e18@amazon.com> <20220825.114727.330127256246111733.horikyota.ntt@gmail.com> <be4c74ba-e229-126b-6dff-0c879c70c547@amazon.com> <20220831.161030.2252231560742777910.horikyota.ntt@gmail.com> <ee63a22a-e702-fdbc-23ea-9459ec9a01e7@amazon.com>

* 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