Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-committers <pgsql-committers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Date: 2021-08-12 08:12:24
Message-ID: CAFiTN-uB+es4B5vsYFQ1hxNOfTfWCxDwG4xCwyRFda9ooG4BaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Thu, Aug 12, 2021 at 1:13 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Thu, Aug 12, 2021 at 3:16 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > On Thu, Aug 12, 2021 at 11:38 AM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
> > >
> > > On Thu, Aug 12, 2021 at 7:39 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> > > >
> > > > On Wed, Aug 11, 2021 at 10:47 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> > > > >
> > > > > On Tue, Aug 10, 2021 at 4:37 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> > > > > >
> > > > > > The apply worker registers SharedFileSetDeleteOnProcExit() when
> > > > > > creating a file set to serialize the changes. When it raises an error
> > > > > > due to conflict during applying the change, the callback eventually
> > > > > > reports the temp file statistics but pgstat already shut down,
> > > > > > resulting in this assertion failure.
> > > > > >
> > > > >
> > > > > I think we can try to fix this by registering to clean up these files
> > > > > via before_shmem_exit() as done by Andres in commit 675c945394.
> > > > > Similar to that commit, we can change the function name
> > > > > SharedFileSetDeleteOnProcExit to SharedFileSetDeleteOnShmExit and
> > > > > register it via before_shmem_exit() instead of on_proc_exit(). Can you
> > > > > try that and see if it fixes the issue for you unless you have better
> > > > > ideas to try out?
> > > >
> > > > It seems to me that moving the shared fileset cleanup to
> > > > before_shmem_exit() is the right approach to fix this problem. The
> > > > issue is fixed by the attached patch.
> > >
> > > +1, the fix makes sense to me.
> > >
> >
> > I have also tested and fix works for me. The fix works because
> > pgstat_initialize() is called before we register clean up in
> > SharedFileSetInit(). I am not sure if we need an Assert to ensure that
> > and if so how we can do that? Any suggestions?
>
> I think that the assertion added by ee3f8d3d3ae ensures that
> pgstat_initialize() is callbed before the callback for fileset cleanup
> is registered, no?

Right, it ensures that callback for fileset, is called after
pgstat_initialize() and before pgstat_shutdown.

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2021-08-12 08:18:23 Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Previous Message Masahiko Sawada 2021-08-12 07:43:11 Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2021-08-12 08:18:23 Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Previous Message Greg Nancarrow 2021-08-12 07:51:24 Re: Skipping logical replication transactions on subscriber side