Re: Parallel vacuum workers prevent the oldest xmin from advancing

Поиск
Список
Период
Сортировка
От Masahiko Sawada
Тема Re: Parallel vacuum workers prevent the oldest xmin from advancing
Дата
Msg-id CAD21AoDtxX2GPgF6g_0UfmD2g7iYS+__0R4dpxLhe+1Pe-KsRQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Parallel vacuum workers prevent the oldest xmin from advancing  (Amit Kapila <amit.kapila16@gmail.com>)
Ответы Re: Parallel vacuum workers prevent the oldest xmin from advancing  (Amit Kapila <amit.kapila16@gmail.com>)
Re: Parallel vacuum workers prevent the oldest xmin from advancing  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
On Thu, Nov 11, 2021 at 12:53 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Thu, Nov 11, 2021 at 9:11 AM Andres Freund <andres@anarazel.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.

Agreed.

This makes me think that it'd be better to copy status flags in a
separate function rather than ProcArrayInstallRestoredXmin(). The
current patch makes use of the fact that ProcArrayInstallRestoedXmin()
acquires a shared lock in order to check the source's status flags.
But if we can acquire an exclusive lock unconditionally in this
context, it’s clearer to do in a separate function.

>
> > 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.

+1

Regards,

--
Masahiko Sawada
EDB:  https://www.enterprisedb.com/



В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: jsonb crash
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: Interrupts vs signals