pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix race condition in snapshot caching when 2PC is used.
Date: Tue, 18 Aug 2020 23:31:04 -0400
Message-ID: <1366053.1597807864@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvpYm5CO9AmryJ0+KXuBMDYw3EryP+ZrA_FNqeuqz966XA@mail.gmail.com>
References: <E1k8BAl-00040m-SM@gemulon.postgresql.org>
	<1355915.1597794204@sss.pgh.pa.us>
	<20200818235152.4hxyb3hrvcm7pwom@alap3.anarazel.de>
	<1356510.1597794950@sss.pgh.pa.us>
	<20200819003713.cm2dg7o7knqnxdny@alap3.anarazel.de>
	<CAApHDvpYm5CO9AmryJ0+KXuBMDYw3EryP+ZrA_FNqeuqz966XA@mail.gmail.com>

David Rowley <dgrowleyml@gmail.com> writes:
>> On 2020-08-18 19:55:50 -0400, Tom Lane wrote:
>>> On Wed, 19 Aug 2020 at 12:37, Andres Freund <andres@anarazel.de> wrote:
>>>> I'm inclined to just make ClearTransaction take an exclusive lock - the
>>>> rest of the 2PC operations are so heavyweight that I can't imagine
>>>> making a difference.  When I tested the locking changes in
>>>> ProcArrayAdd()/Remove() the more heavyweight locking wasn't at all
>>>> visible.

>>> I was wondering if it'd be sensible to convert that counter into an
>>> atomic variable.  That's not real clear, but worth thinking about.

> Couldn't it be done by creating two inline functions, one to call to
> atomically increment and the other to just increment?  Can backup that
> the correct version of the function is being called with an
> Assert(LWLockHeldByMeInMode(ProcArrayLock, ...));

On reflection I agree with Andres' thought that just taking the lock
exclusively in ProcArrayClearTransaction is the right solution.
It's silly to imagine that a 2PC commit (plus all the other stuff that
needs to happen around that) is fast enough that that'll be a serious
performance hit.  Keeping things simple for the other code paths is
a more useful goal.

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <1366053.1597807864@sss.pgh.pa.us>
Permalink:  ../1366053.1597807864@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1366053.1597807864@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, andres@anarazel.de
  Subject: Re: pgsql: Fix race condition in snapshot caching when 2PC is used.
  In-Reply-To: <1366053.1597807864@sss.pgh.pa.us>
  References: <E1k8BAl-00040m-SM@gemulon.postgresql.org> <1355915.1597794204@sss.pgh.pa.us> <20200818235152.4hxyb3hrvcm7pwom@alap3.anarazel.de> <1356510.1597794950@sss.pgh.pa.us> <20200819003713.cm2dg7o7knqnxdny@alap3.anarazel.de> <CAApHDvpYm5CO9AmryJ0+KXuBMDYw3EryP+ZrA_FNqeuqz966XA@mail.gmail.com> <1366053.1597807864@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox