Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJmMY-0005kW-9C for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Sep 2013 15:29:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VJmMX-0007Rl-H6 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Sep 2013 15:29:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJmMW-0007RV-Ij for pgsql-hackers@postgresql.org; Wed, 11 Sep 2013 15:29:48 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJmMT-00019o-Tr for pgsql-hackers@postgresql.org; Wed, 11 Sep 2013 15:29:48 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 130375F773; Wed, 11 Sep 2013 11:32:01 -0400 (EDT) Date: Wed, 11 Sep 2013 11:32:01 -0400 From: Stephen Frost To: Noah Misch Cc: pgsql-hackers@postgresql.org Subject: Re: Weaker shmem interlock w/o postmaster.pid Message-ID: <20130911153200.GD2706@tamriel.snowman.net> References: <20130911033341.GD225735@tornado.leadboat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gkiDa84Y9ghbahcQ" Content-Disposition: inline In-Reply-To: <20130911033341.GD225735@tornado.leadboat.com> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.8.0-25-generic (x86_64) X-Uptime: 10:40:51 up 60 days, 10:50, 7 users, load average: 0.08, 0.04, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.7 (--) 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 --gkiDa84Y9ghbahcQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Noah Misch (noah@leadboat.com) wrote: > Shouldn't it instead check the same things as PGSharedMemoryIsInUse()? Offhand, I tend to agree that we should really be doing a very careful job of looking at if an existing segment is still in use. > The concrete situation in which I encountered this involved PostgreSQL 9.= 2 and > an immediate shutdown with a backend that had blocked SIGQUIT. The backe= nd > survived the immediate shutdown as one would expect. =20 Well.. We expect this now because of the analysis you did in the adjacent thread showing how it can happen. > The postmaster > nonetheless removed postmaster.pid before exiting, and I could immediately > restart PostgreSQL despite the survival of the SIGQUIT-blocked backend. = If I > instead SIGKILL the postmaster, postmaster.pid remains, and I must kill s= tray > backends before restarting. The postmaster should not remove postmaster.= pid > unless it has verified that its children have exited. This makes sense, however.. > Concretely, that means > not removing postmaster.pid on immediate shutdown in 9.3 and earlier. Th= at's > consistent with the rough nature of an immediate shutdown, anyway. I don't like leaving the postmaster.pid file around, even on an immediate shutdown. I don't have any great suggestions regarding what to do, given what we try to do wrt 'immediate', so perhaps it's acceptable for future releases. > I'm thinking to preserve postmaster.pid at immediate shutdown in all rele= ased > versions, but I'm less sure about back-patching a change to make > PGSharedMemoryCreate() pickier. On the one hand, allowing startup to pro= ceed > with backends still active in the same data directory is a corruption haz= ard. The corruption risk, imv anyway, is sufficient to backpatch the change and overrides the concerns around very fast shutdown/restarts. Thanks, Stephen --gkiDa84Y9ghbahcQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlIwjPAACgkQrzgMPqB3kiiqHACeKEXZp2CoKoJioJdM6Ec4++X3 v3AAn2Z/cB448IXmTZ+iQsc3YiMxloeL =9lor -----END PGP SIGNATURE----- --gkiDa84Y9ghbahcQ--