Re: Resetting spilled txn statistics in pg_stat_replication

From: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Resetting spilled txn statistics in pg_stat_replication
Date: 2020-10-12 23:23:50
Message-ID: CA+fd4k61TZ2L39pd+xEr-BnpqHdk1aBf3gHC=7q69LN+TKaaPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 12 Oct 2020 at 19:24, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Mon, Oct 12, 2020 at 10:59 AM Masahiko Sawada
> <masahiko(dot)sawada(at)2ndquadrant(dot)com> wrote:
> >
> > On Thu, 8 Oct 2020 at 17:59, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> > >
> > > On Thu, Oct 8, 2020 at 1:55 PM Masahiko Sawada
> > > <masahiko(dot)sawada(at)2ndquadrant(dot)com> wrote:
> > > >
> > > > On Thu, 8 Oct 2020 at 14:10, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> > > > >
> > > > >
> > > > > We can write if we want but there are few things we need to do for
> > > > > that like maybe a new function like wait_for_spill_stats which will
> > > > > check if the counters have become zero. Then probably call a reset
> > > > > function, call a new wait function, and then again check stats to
> > > > > ensure they are reset to 0.
> > > >
> > > > Yes.
> > > >
> > >
> > > I am not sure if it is worth but probably it is not a bad idea
> > > especially if we extend the existing tests based on your below idea?
> > >
> > > > > We can't write any advanced test which means reset the existing stats
> > > > > perform some tests and again check stats because *slot_get_changes()
> > > > > function can start from the previous WAL for which we have covered the
> > > > > stats. We might write that if we can somehow track the WAL positions
> > > > > from the previous test. I am not sure if we want to go there.
> > > >
> > > > Can we use pg_logical_slot_peek_changes() instead to decode the same
> > > > transactions multiple times?
> > > >
> > >
> > > I think this will do the trick. If we want to go there then I suggest
> > > we can have a separate regression test file in test_decoding with name
> > > as decoding_stats, stats, or something like that. We can later add the
> > > tests related to streaming stats in that file as well.
> > >
> >
> > Agreed.
> >
> > I've updated the patch. Please review it.
> >
>
> Few comments:
> =============

Thank you for your review.

> 1.
> +-- function to wait for counters to advance
> +CREATE FUNCTION wait_for_spill_stats(check_reset bool) RETURNS void AS $$
>
> Can we rename this function to wait_for_decode_stats? I am thinking we
> can later reuse this function for streaming stats as well by passing
> the additional parameter 'stream bool'.

+1. Fixed.

>
> 2. let's drop the table added by this test and regression_slot at the
> end of the test.

Fixed.

Attached the updated version patch. Please review it.

Regards,

--
Masahiko Sawada http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v11-0001-Test-stats.patch application/octet-stream 6.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2020-10-13 00:10:51 Re: Resetting spilled txn statistics in pg_stat_replication
Previous Message Thomas Munro 2020-10-12 23:18:11 Re: Assertion failure with barriers in parallel hash join