Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBrgn-0006g2-DQ for pgsql-committers@arkaria.postgresql.org; Thu, 04 Apr 2019 02:01:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hBrgl-0000D6-2j for pgsql-committers@arkaria.postgresql.org; Thu, 04 Apr 2019 02:01:11 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBrgj-0000Cz-Ve for pgsql-committers@lists.postgresql.org; Thu, 04 Apr 2019 02:01:10 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBrgc-0002Fu-0z for pgsql-committers@lists.postgresql.org; Thu, 04 Apr 2019 02:01:09 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id BC6FB21FAE; Wed, 3 Apr 2019 22:01:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 03 Apr 2019 22:01:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=fm1; bh=h wMluhzpylbzjjhkEMtSNvX7je/KdkAWXXqP6XQBJEg=; b=HLdjW+1oB/yC3G9dG ghQPG7W/d8VcTLg/3dpYRzw8Y5lhyg5sQ6VF/RlQxo3OpAjp4WOV0RQvbM6T/MVz M44rcXDw+yWiIohHHzXmOQODWZwK8uTDtFX19kGYY8OOZ7z/AHJR2+troGv/59Ng KRvp1oa3zYWsEyOkhYXUg7OwjEg/zhmDBQELmi+FH4SrtIqhLW+G6THTDwwsrji8 mykxZTDLnyVXAyrMyJdX4lyyjCYzcPJWCGscw6jr704fiTE9FnlSS1js4uGlnqjN 1Cs3E23tD3sw1n+k2fSbCT1rkAn3V8USjVA2lyWIM5YKA1XZOy9xmY/kHJCoPkYb 6m/MQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=hwMluhzpylbzjjhkEMtSNvX7je/KdkAWXXqP6XQBJ Eg=; b=KYNWpleMUbNKJQMHlXqUSVpFNP3GLbIMDq5JY92N3LloddVw4Dc5FHw6j TcYibjyUZ87u5klMndqRZMk/CiC+cuBg0723ojEg+5JOZmCWMZy9rMP72lkq7WQt Hb1Wah2qdUaGM/WRp6060hMoabbfSa0plpu4vI8Vp7jmjojgrnZASN9VRnE7w7zN vELV7wEDsUH4wD4lAx4wZ0pTj85+ilRGYBPtpZEuVTNIs1Qa7JtAS2gaHOip+726 ITxaF5fyO+j6DhocCLTzUI6HeBKAI03f5RKhin8cQEsBeycmcGcPxQQ28N2NgYq4 +Z8OWty6xnYGmui6tpE1WDZVPlLbg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrtdeggdehudculddtuddrgedutddrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvuffkfhggtggugfgjsehtkeertddttdej necuhfhrohhmpeetnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgrii gvlhdruggvqeenucffohhmrghinhepphhoshhtghhrrdgvshenucfkphepleekrddvuddt rddugedtrddujedunecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrg hrrgiivghlrdguvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id DA498E4424; Wed, 3 Apr 2019 22:00:59 -0400 (EDT) Date: Wed, 3 Apr 2019 19:00:57 -0700 From: Andres Freund To: Noah Misch Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Consistently test for in-use shared memory. Message-ID: <20190404020057.galelv7by75ekqrh@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-04-04 00:16:55 +0000, Noah Misch wrote: > Consistently test for in-use shared memory. > > postmaster startup scrutinizes any shared memory segment recorded in > postmaster.pid, exiting if that segment matches the current data > directory and has an attached process. When the postmaster.pid file was > missing, a starting postmaster used weaker checks. Change to use the > same checks in both scenarios. This increases the chance of a startup > failure, in lieu of data corruption, if the DBA does "kill -9 `head -n1 > postmaster.pid` && rm postmaster.pid && pg_ctl -w start". A postmaster > will no longer recycle segments pertaining to other data directories. > That's good for production, but it's bad for integration tests that > crash a postmaster and immediately delete its data directory. Such a > test now leaks a segment indefinitely. No "make check-world" test does > that. win32_shmem.c already avoided all these problems. In 9.6 and > later, enhance PostgresNode to facilitate testing. Back-patch to 9.4 > (all supported versions). > > Reviewed by Daniel Gustafsson and Kyotaro HORIGUCHI. > > Discussion: https://postgr.es/m/20130911033341.GD225735@tornado.leadboat.com My compiler now nitpicks: In file included from /home/andres/src/postgresql/src/include/postgres.h:47, from pg_shmem.c:20: pg_shmem.c: In function ‘PGSharedMemoryCreate’: /home/andres/src/postgresql/src/include/utils/elog.h:122:5: warning: this statement may fall through [-Wimplicit-fallthrough=] do { \ ^ /home/andres/src/postgresql/src/include/utils/elog.h:142:2: note: in expansion of macro ‘ereport_domain’ ereport_domain(elevel, TEXTDOMAIN, rest) ^~~~~~~~~~~~~~ pg_shmem.c:668:5: note: in expansion of macro ‘ereport’ ereport(FATAL, ^~~~~~~ pg_shmem.c:675:4: note: here case SHMSTATE_ENOENT: ^~~~ All of PostgreSQL successfully made. Ready to install. I think the SHMSTATE_ATTACHED case simply should grow a (unreachable) break. But I'd also strongly suggest adding one to SHMSTATE_UNATTACHED - because that's actually reachable, and just seems like a trap for person adding another case:. Greetings, Andres Freund