pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@postgreSQL.org
Subject: Broken order-of-operations in parallel query latch manipulation
Date: Sun, 31 Jul 2016 16:28:31 -0400
Message-ID: <1661.1469996911@sss.pgh.pa.us> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Both shm_mq.c and nodeGather.c contain instances of this coding pattern:

            WaitLatch(MyLatch, WL_LATCH_SET, 0);
            CHECK_FOR_INTERRUPTS();
            ResetLatch(MyLatch);

I believe this is wrong and the CHECK_FOR_INTERRUPTS needs to be before
or after the two latch operations.  As-is, if the reason somebody set
our latch was to get us to notice that a CHECK_FOR_INTERRUPTS condition
happened, there's a race condition where we'd fail to realize that.
Other places such as ProcWaitForSignal() do it that way; only recently
introduced (and unproven in the field) code has it like this.

Anyone want to argue it's okay as-is?

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (4+ messages)  latest in thread

Message-ID: <1661.1469996911@sss.pgh.pa.us>
Permalink:  ../1661.1469996911@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1661.1469996911@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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: Broken order-of-operations in parallel query latch manipulation
  In-Reply-To: <1661.1469996911@sss.pgh.pa.us>
  References: <1661.1469996911@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