Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLWnM-008TEp-2O for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jan 2024 23:06:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rLWnK-00G1FQ-HZ for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jan 2024 23:06:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLWnK-00G1FH-7u for pgsql-hackers@lists.postgresql.org; Thu, 04 Jan 2024 23:06:34 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLWnH-00FZgb-VL for pgsql-hackers@lists.postgresql.org; Thu, 04 Jan 2024 23:06:33 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 34C0B5C0263; Thu, 4 Jan 2024 18:06:30 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 04 Jan 2024 18:06:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1704409590; x=1704495990; bh=uNl+rbdKQH dMo2pbQZnwt32lCuISJBv5PhaRyCTGjMk=; b=gvreGQLFMe4PM9W3ZIkfqf/bGF CnMZNgpdx3G/jJAkD1qDY3MrMQeHMmV4JeeXlAO+qgj+OLF5ReNzkrpuQi7ZN8Hg u9JXjGoH2UB17DKu5680mxwd1hbjZvtSKKpK4RbC27htl7SyY+ko5FfIWooIorw4 +TpELfn/E0lhqaLQGz/p3FiTE9UC9IevNLYp7phWZjrHTrYAmdicU5eWfqqARbRd MRjcDgZegNZemE4BybkS128MX/GRVC/ZeDYo28s4Ct+Xcp3sBzP0785rDlr0grSU H4x3L5VEludLDxfc+E1WJkDjdi9BFE5AuglToim4v6CSJ3j6hpUVNdfEnckw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1704409590; x=1704495990; bh=uNl+rbdKQHdMo2pbQZnwt32lCuIS JBv5PhaRyCTGjMk=; b=BiHLGDJHwXozF4448lcC1QnlrEG039ui+hD3v0mCgeXu ZZ/CIniYneuwj9WJ8rKEUOnEOq/bN5wOpvhHHq7oPwJVLsdvK4C+ajHhwxPaBh4X VsqDg8fdDkw79Y0LW9iOuQon5iv9AJ+VwYeWLnqotpA9F+Lbpk2geMQJsJu30KB5 DPyMqwVRgg3gywyrCBhlCbJLB0fnX1H+3ZH6EU06S9rPiU6zbQdeUy61nI/2IrKB NiScj1dr3OP44cb36kKeVqV12Rd03eY3hKiH4gt7wEuK7JFeycDUxPN2Ex8nLyek hC4bxVNIEK+Z/nrAHtPAECdnoxM892G8d25XZiCqUQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdegkedgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetvedu ieettddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Jan 2024 18:06:29 -0500 (EST) Date: Thu, 4 Jan 2024 15:06:28 -0800 From: Andres Freund To: Andy Fan Cc: PostgreSQL Hackers , Thomas Munro Subject: Re: the s_lock_stuck on perform_spin_delay Message-ID: <20240104230628.j2wqqck3wrgol6ym@awork3.anarazel.de> References: <87plyhvama.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87plyhvama.fsf@163.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2024-01-04 14:59:06 +0800, Andy Fan wrote: > My question is if someone doesn't obey the rule by mistake (everyone > can make mistake), shall we PANIC on a production environment? IMO I > think it can be a WARNING on a production environment and be a stuck > when 'ifdef USE_ASSERT_CHECKING'. > > [...] > > I notice this issue actually because of the patch "Cache relation > sizes?" from Thomas Munro [1], where the latest patch[2] still have the > following code. > + sr = smgr_alloc_sr(); <-- HERE a spin lock is hold > + > + /* Upgrade to exclusive lock so we can create a mapping. */ > + LWLockAcquire(mapping_lock, LW_EXCLUSIVE); <-- HERE a complex > operation is needed. it may take a long time. > > Our internal testing system found more misuses on our own PG version. > I think a experienced engineer like Thomas can make this mistake and the > patch was reviewed by 3 peoples, the bug is still there. It is not easy > to say just don't do it. I don't follow this argument - just ignoring the problem, which emitting a WARNING basically is, doesn't reduce the impact of the bug, it *increases* the impact, because now the system will not recover from the bug without explicit operator intervention. During that time the system might be essentially unresponsive, because all backends end up contending for some spinlock, which makes investigating such issues very hard. I think we should add infrastructure to detect bugs like this during development, but not PANICing when this happens in production seems completely non-viable. Greetings, Andres Freund