Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzRGd-0000m2-V7 for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Oct 2017 17:46:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dzRGd-0006BR-Hg for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Oct 2017 17:46:03 +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 1dzRF4-0003M1-Ku for pgsql-hackers@postgresql.org; Tue, 03 Oct 2017 17:44:26 +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 1dzRF1-0003xX-LH for pgsql-hackers@postgresql.org; Tue, 03 Oct 2017 17:44:26 +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 v93HiC7U023455; Tue, 3 Oct 2017 13:44:12 -0400 From: Tom Lane To: Alvaro Herrera cc: Andres Freund , Andreas Seltenreich , pgsql-hackers@postgresql.org, Michael Paquier , Peter Eisentraut , Petr Jelinek Subject: Re: [sqlsmith] stuck spinlock in pg_stat_get_wal_receiver after OOM In-reply-to: <6526.1507049903@sss.pgh.pa.us> References: <20171003145023.nc2ffduj3qvy4b5b@alvherre.pgsql> <22735.1507048202@sss.pgh.pa.us> <6526.1507049903@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 03 Oct 2017 12:58:23 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23453.1507052652.1@sss.pgh.pa.us> Date: Tue, 03 Oct 2017 13:44:12 -0400 Message-ID: <23454.1507052652@sss.pgh.pa.us> 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 I wrote: >> So that's trouble waiting to happen, for sure. At the very least we >> need to do a single fetch of WalRcv->latch, not two. I wonder whether >> even that is sufficient, though: this coding requires an atomic fetch of >> a pointer, which is something we generally don't assume to be safe. BTW, I had supposed that this bug was of long standing, but actually it's new in v10, dating to 597a87ccc9a6fa8af7f3cf280b1e24e41807d555. Before that walreceiver start/stop just changed the owner of a long-lived shared latch, and there was no question of stale pointers. I considered reverting that decision, but the reason for it seems to have been to let libpqwalreceiver.c manipulate MyProc->procLatch rather than having to know about a custom latch. That's probably a sufficient reason to justify some squishiness in the wakeup logic. Still, we might want to revisit it if we find any other problems here. 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