Re: Fix pg_stat_reset_single_table_counters function

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org, mitsuru(dot)hinata(dot)5432(at)gmail(dot)com
Subject: Re: Fix pg_stat_reset_single_table_counters function
Date: 2023-08-15 02:48:30
Message-ID: CAD21AoDhhdicG3rYwKq3fLngn=T4qRuFiOWtqeYFwMM_-R43WQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Aug 14, 2023 at 5:12 PM Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com> wrote:
>
> Hi,
>
> On 2023-08-13 04:12, Andres Freund wrote:
> > On 2023-08-10 17:48:10 +0900, Masahiko Sawada wrote:
> >> Good catch! I've confirmed that the issue has been fixed by your
> >> patch.
> >
> > Indeed.
>
> Thanks for your responses!
>
> >> However, I'm not sure the added regression tests are stable since
> >> autovacuum workers may scan the pg_database and increment the
> >> statistics after resetting the stats.
> >
> > What about updating the table and checking the update count is reset?
> > That'd
> > not be reset by autovacuum.
>
> Yes. I confirmed that the stats are incremented by autovacuum as you
> said.
>
> I updated the patch to v3.
> * remove the code to bump the CATALOG_VERSION_NO because I misunderstood
> * change the test logic to check the update count instead of scan count

Thank you for updating the patch!

>
> I changed the table to check the stats from pg_database to
> pg_shdescription
> because the stats can update via the SQL interface COMMENT command.

It seems to work well.

+COMMENT ON DATABASE :current_database IS 'This is a test comment';
-- insert or update in 'pg_shdescription'

I think the current_database should be quoted (see other examples
where using current_database(), e.g. collate.linux.utf8.sql). Also it
would be better to reset the comment after the test.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-08-15 03:06:11 Re: [PoC] pg_upgrade: allow to upgrade publisher node
Previous Message Peter Smith 2023-08-15 02:38:28 Re: logicalrep_worker_launch -- counting/checking the worker limits