Re: Parallel vacuum workers prevent the oldest xmin from advancing - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Parallel vacuum workers prevent the oldest xmin from advancing
Date
Msg-id 20211111034153.ekclyrp7oso5wtd4@alap3.anarazel.de
Whole thread Raw
In response to Re: Parallel vacuum workers prevent the oldest xmin from advancing  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: Parallel vacuum workers prevent the oldest xmin from advancing
List pgsql-hackers
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.

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.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Weird failure in explain.out with OpenBSD
Next
From: Noah Misch
Date:
Subject: Re: 2021-11-11 release announcement draft