Re: Parallel vacuum workers prevent the oldest xmin from advancing

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Parallel vacuum workers prevent the oldest xmin from advancing
Date: 2021-11-11 03:53:22
Message-ID: CAA4eK1LP7i84=N2vFP5sWpjMRKGsEe7Ov62T8eMkUnSJNLYDPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 11, 2021 at 9:11 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
>
> Hi,
>
> On 2021-11-11 12:22:42 +0900, Masahiko Sawada wrote:
> > > 2.
> > > LWLockAcquire(ProcArrayLock, LW_SHARED);
> > >
> > > + flags = proc->statusFlags;
> > > +
> > > + /*
> > > + * If the source xact has any statusFlags, we re-grab ProcArrayLock
> > > + * on exclusive mode so we can copy it to MyProc->statusFlags.
> > > + */
> > > + if (flags != 0)
> > > + {
> > > + LWLockRelease(ProcArrayLock);
> > > + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
> > > + }
> > >
> > >
> > > This looks a bit odd to me. It would have been better if we know when
> > > to acquire an exclusive lock without first acquiring the shared lock.
> >
> > I think we should acquire an exclusive lock only if status flags are
> > not empty. But to check the status flags we need to acquire a shared
> > lock. No?
>
> This seems like an unnecessary optimization. ProcArrayInstallRestoredXmin()
> only happens in the context of much more expensive operations.
>

Fair point. I think that will also make the change in
ProcArrayInstallRestoredXmin() appear neat.

> I think it might be worth asserting that the set of flags we're copying is a
> known subset of the flags that are valid to copy from the source.
>

Sounds reasonable.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2021-11-11 04:07:32 Re: [BUG]Invalidate relcache when setting REPLICA IDENTITY
Previous Message Noah Misch 2021-11-11 03:47:16 Re: 2021-11-11 release announcement draft