Re: Resetting spilled txn statistics in pg_stat_replication

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>
Cc: 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-07-16 11:01:06
Message-ID: CAA4eK1JF2miZVSDW0noTZunk482tonoyJNUrf5Hrodwxu7GmoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 16, 2020 at 4:04 PM Masahiko Sawada
<masahiko(dot)sawada(at)2ndquadrant(dot)com> wrote:
>
> On Thu, 16 Jul 2020 at 18:16, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > On Thu, Jul 16, 2020 at 1:45 PM Masahiko Sawada
> > <masahiko(dot)sawada(at)2ndquadrant(dot)com> wrote:
> > >
> > > A possible solution would be to add an in-use flag to
> > > PgStat_ReplSlotStats indicating whether the stats for slot is used or
> > > not. When receiving a drop message for a slot, the stats collector
> > > just marks the corresponding stats as unused. When receiving the stats
> > > report for a new slot but there is no unused stats slot, ignore it.
> > > What do you think?
> > >
> >
> > As of now, you have a boolean flag msg.m_drop to distinguish the drop
> > message but we don't have a similar way to distinguish the 'create'
> > message. What if have a way to distinguish 'create' message (we can
> > probably keep some sort of flag to indicate the type of message
> > (create, drop, update)) and then if the slot with the same name
> > already exists, we ignore such a message. Now, we also need a way to
> > create the entry for a slot for a normal stats update message as well
> > to accommodate for the lost 'create' message. Does that make sense?
>
> I might be missing your point, but even if we have 'create' message,
> the problem can happen if when slots are full the user drops slot
> ‘slot_a’, creates slot ‘slot_b', and messages arrive in the reverse
> order?
>

In that case, also, we should drop the 'create' message of 'slot_b' as
we don't have space but later when an 'update' message arrives with
stats for the 'slot_b', we will create the entry. I am also thinking
what if send only 'update' and 'drop' message, the message ordering
problem can still happen but we will lose one 'update' message in that
case?

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-07-16 11:45:55 Re: OpenSSL 3.0.0 compatibility
Previous Message Amit Kapila 2020-07-16 10:55:32 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions