Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTxN8-0000Gi-5f for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Jul 2016 20:30:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bTxN7-0006l5-LR for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Jul 2016 20:30:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bTxLk-0004Gl-HA for pgsql-hackers@postgreSQL.org; Sun, 31 Jul 2016 20:28:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bTxLd-0001fF-5N for pgsql-hackers@postgreSQL.org; Sun, 31 Jul 2016 20:28:39 +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 u6VKSV9S001662 for ; Sun, 31 Jul 2016 16:28:31 -0400 From: Tom Lane 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> X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org 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