Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAd63-0008Q1-Ap for pgsql-committers@arkaria.postgresql.org; Thu, 20 Jan 2022 19:27:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nAd61-0008Pc-Up for pgsql-committers@arkaria.postgresql.org; Thu, 20 Jan 2022 19:27:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAd5z-0008OH-Tl for pgsql-committers@lists.postgresql.org; Thu, 20 Jan 2022 19:27:45 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAd5w-0002Ne-S6 for pgsql-committers@lists.postgresql.org; Thu, 20 Jan 2022 19:27:42 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id D495B5C022F; Thu, 20 Jan 2022 14:27:38 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 20 Jan 2022 14:27:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=aUM/Do4g6fmYTyU5kzKBsjWegG01ZfAJwX2xTK d5K38=; b=WxCodo0K7Dyi30+awAc8XYZkIQEZZHqURVfU1w3OLo4zbJN+t1RSLZ QjzgZmCceYwWCXpYj1IpCC4vkynqHw4nqIRTbBc/lCowIJQpmgGKd933hk4Jyb2M mSON1ROnKZOzdbLwXpjEJfauLSD1fimA7YstizbDuh+Dchn1JARwCf8IyGv1xuKx wQ3x36qw2AllGqiqY9VmtYAzmNMKGEjP3SFJAFcgjuv8rKGaWyeGE06vZ1hsoz9M IWOqIfoOOSM8hBH2GpLdpGqjF1IrNhqFwX72xIy2b/HlqjIEHJBNUscji5vwCsjG uqXlufcco89bMpcBrqyf7FF3ir0nf/gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=aUM/Do4g6fmYTyU5k zKBsjWegG01ZfAJwX2xTKd5K38=; b=IH+UMSItwJ5xEfj8qd1dP81JcZTGsbmxo n4omcDesIGMZ9GbTov1a7JL055tQZwOn02Rd2uW6HnUIDI7AnIDybMzB+L9evb5/ SIEFLURObBiz6ajZTWtKif4f0NV7nK05Kvn5Na/GRtetCpo/qtyZcN6NbHPz03eW 5PYWgjE8eMBAfFmRMbd/DCEQ6VIRmNKww6zf1aqjc5ii40UjSGSQ/yNEQ7tAHkKo vID0Myktj9lGH18zWD5pvz97Lktwnst2heM8GVZRZilt9z1JccWKu8RjLsXwrc14 jLlt3vDtanA+OMQTqLuflrUnOoBiWtyxqilkQxs9jwtC5LOpZPa2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekgdduvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpeehfefhgeejjeevfefhtddvteegffekheffkedtgfeggeeufeefkeeviedt jeduvdenucffohhmrghinhepphhgshhqlhdrsghuihhlugenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghl rdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 Jan 2022 14:27:37 -0500 (EST) Date: Thu, 20 Jan 2022 11:27:36 -0800 From: Andres Freund To: Tom Lane , Noah Misch Cc: Thomas Munro , pgsql-committers Subject: Re: pgsql: TAP tests: check for postmaster.pid anyway when "pg_ctl start" f Message-ID: <20220120192736.msyesvdlljn6tptw@alap3.anarazel.de> References: <855583.1642687119@sss.pgh.pa.us> <867290.1642689136@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <867290.1642689136@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-01-20 09:32:16 -0500, Tom Lane wrote: > Seems like we need to do 'kill 0' on the PID we get from > the file to verify that there's really a postmaster there. > (I wonder how well that works on Windows? perlport claims > it does, but ...) We seem to successfully do that in pg_ctl's postmaster_is_alive(). > I wrote: > > Hmm. I think the problem is that poll_start() thinks it can just call > > start() a second time after a failure. If it wasn't a true failure > > but a timeout, then _pid is now set and the second call complains. > > Oh, wait --- the case that is failing is after 017_shm.pl has > intentionally kill -9'd a postmaster, so that its pidfile is > left behind. The next attempted start fails on shmem id > conflict, but it doesn't remove the old pidfile, and then > the code I added to sub start erroneously picks that up > as a live postmaster PID. > I fear I still don't have the whole story though because > per this theory it should fail everywhere, yet it doesn't. The sequence in regress_log_* that hoverfly is getting and that I am seeing locally differs. It's a bit hard to tell, because the test doesn't report any test progress until quite a bit into the test... For the first kill9, I see: local: ### Killing node "gnat" using signal 9 ... ### Starting node "gnat" # Running: pg_ctl -w -D /home/andres/build/postgres/dev-assert/vpath/src/test/recovery/tmp_check/t_017_shm_gnat_data/pgdata -l /home/andres/build/postgres/dev> pg_ctl: another server might be running; trying to start server anyway waiting for server to start.... done server started # Postmaster PID for node "gnat" is 2904505 hoverfly: ### Killing node "gnat" using signal 9 ... ### Starting node "gnat" # Running: pg_ctl -w -D /scratch/nm/farm/xlc64v16/HEAD/pgsql.build/src/test/recovery/tmp_check/t_017_shm_gnat_data/pgdata -l /scratch/nm/farm/xlc64v16/HEAD/pgsql.build/src/test/recovery/tmp_check/log/017_shm_gnat.log -o --cluster-name=gnat start pg_ctl: another server might be running; trying to start server anyway waiting for server to start.... stopped waiting pg_ctl: could not start server Examine the log output. # pg_ctl start failed; logfile: local log: 2022-01-20 11:02:40.109 PST [2905213] LOG: starting PostgreSQL 15devel on x86_64-pc-linux-gnu, compiled by gcc-12 (Debian 12-20220106-1) 12.0.0 20220106 (experimental) [master r12-6277-g1935db29689], 64-bit 2022-01-20 11:02:40.109 PST [2905213] LOG: listening on Unix socket "/tmp/jAyaRMImQH/.s.PGSQL.53851" 2022-01-20 11:02:40.110 PST [2905216] LOG: database system was interrupted; last known up at 2022-01-20 11:02:39 PST 2022-01-20 11:02:40.111 PST [2905216] LOG: database system was not properly shut down; automatic recovery in progress hoverfly: 2022-01-20 18:04:53.087 UTC [50659690:1] LOG: starting PostgreSQL 15devel on powerpc-ibm-aix7.2.4.0, compiled by /opt/IBM/xlc/16.1.0/bin/xlc_r -D_LARGE_FILES=1 -DRANDOMIZE_ALLOCATED_MEMORY, 64-bit 2022-01-20 18:04:53.088 UTC [50659690:2] LOG: listening on Unix socket "/home/nm/farm/tmp/oR5PbI8A5R/.s.PGSQL.61673" 2022-01-20 18:04:53.092 UTC [393770:1] LOG: database system was shut down at 2022-01-20 18:04:52 UTC 2022-01-20 18:04:53.099 UTC [50659690:3] LOG: database system is ready to accept connections 2022-01-20 18:04:53.275 UTC [33751596:1] FATAL: lock file "postmaster.pid" already exists 2022-01-20 18:04:53.275 UTC [33751596:2] HINT: Is another postmaster (PID 50659690) running in data directory "/scratch/nm/farm/xlc64v16/HEAD/pgsql.build/src/test/recovery/tmp_check/t_017_shm_gnat_data/pgdata"? IOW, the test doesn't actually quite seem to be working in the "local" case? Hence not seeing the problem of picking up some wrong pid. I think it's a question of how quick the postmaster-death detection logic is. At first I thought it's a question of USE_POSTMASTER_DEATH_SIGNAL, but I see the same with the pipe based approach. So it's probably just a question of event ordering. I think this test could benefit from $gnat->append_conf('postgresql.conf', 'log_min_messages=debug3'); or such, so that we see processes exiting. I also think we ought to emit a debug message when detecting postmaster death. It's unnecessarily hard to debug them right now. Greetings, Andres Freund