Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXLid-0002L8-WF for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2018 06:43:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXLid-000202-6w for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2018 06:43:07 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eXLic-0001zr-Ny for pgsql-hackers@lists.postgresql.org; Fri, 05 Jan 2018 06:43:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eXLiV-0006DX-UV for pgsql-hackers@postgresql.org; Fri, 05 Jan 2018 06:43:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w056gtMZ023235; Fri, 5 Jan 2018 01:42:55 -0500 From: Tom Lane To: Thomas Munro cc: Andres Freund , Robert Haas , Pg Hackers Subject: Re: Condition variable live lock In-reply-to: References: <20171229193843.tsbob2xsjfmxkq2g@alap3.anarazel.de> <20180104205447.mdaub47aunp3h3mq@alap3.anarazel.de> <17054.1515126429@sss.pgh.pa.us> <21761.1515132657@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Fri, 05 Jan 2018 19:33:10 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23233.1515134575.1@sss.pgh.pa.us> Date: Fri, 05 Jan 2018 01:42:55 -0500 Message-ID: <23234.1515134575@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > On Fri, Jan 5, 2018 at 7:10 PM, Tom Lane wrote: >> Should we rejigger the logic so that it awakens one additional waiter >> (if there is one) after detecting that someone else has removed the >> sentinel? Obviously, this trades a risk of loss of wakeup for a risk >> of spurious wakeup, but presumably the latter is something we can >> cope with. > One detail is that the caller of ConditionVariableSignal() got a true > return value when it took out the sentinel (indicating that someone > received the signal), and now when you call ConditionVariableSignal() > because !aminlist there may be no one there. I'm not sure if that's a > problem. For comparison, pthread_cond_signal() doesn't tell you if > you actually signalled anyone. Maybe the only reason we have that > return code is so that ConditionVariableBroadcast() can use it the way > it does in master... Indeed, it looks like no other caller is paying attention to the result. We could live with the uncertainty in the back branches, and redefine ConditionVariableSignal as returning void in master. regards, tom lane