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 1rLpch-000l7U-4I for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2024 19:12:52 +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 1rLpbg-0036n1-Pp for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2024 19:11:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLpbf-0036in-0B for pgsql-hackers@lists.postgresql.org; Fri, 05 Jan 2024 19:11:48 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLpbb-0003Mn-ED for pgsql-hackers@lists.postgresql.org; Fri, 05 Jan 2024 19:11:45 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 133FB5C01F7; Fri, 5 Jan 2024 14:11:41 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 05 Jan 2024 14:11:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding: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=1704481901; x=1704568301; bh=1NYqXTfVYqhdeHAp8grP2T4CT4IDwtIJ0KD4IrYGkYE=; b= hLX+v2jmuNz0TKBAX9YM1UX7M6fG+8GTfNMa6Se3EtgoLZEK0MMrNh8fCaRQSfUZ Jf+dLYFWHQcZdcCreoVcUDP/5c9lsdWBiJyLwaGoQ7VrZMYu3L8Cggd7SflFcqs2 fWnftTtBU7i9fL7gpt41EnajfCcFTO6UYjdAQWRMtVxqZo6KJwyiY9CZrIRwkPeC zell9xm5B+ehZoilluqNDAUbkzoa0810iGEJLM9LG2jpXmmUYhjWfzJ6OIDG107i CfLhNyqQFy6wisOHwRSbWtES942yGRH8UqdoewanmZhaQSefhl06IYpHJMS/hfmx oei/lUPmuLt9iUL5gZXT5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1704481901; x= 1704568301; bh=1NYqXTfVYqhdeHAp8grP2T4CT4IDwtIJ0KD4IrYGkYE=; b=b 0QbGO7g5BzAyD5aZEjH5nId6c32Y4ywJE03xnGTTp1hJde/jH0TWAxRjUBoovKbz CQSeQPALepeWiq858C2t71mR810bhFIIW8tlFHz44aU8BWXwXUbj+oarfPo4k2s4 4s0Krr8oAAd2TOIJrJXFnWmFUs1QzJtPLWBQSUp9zWcf3rDyEfB13/jCwyj9m7vH cVti3ZevFvYa9Tway7n/wZ78AeFmac4yIQHh+SBFrPa/Kp/at+WDWdZaqDD+Ai3K d2WcTBv3zuPaAXRq1K9HonUczg6KIsNsE9d2vjGCCVTrrv5QD6vDxlP3RkhbiBjj Npp6DAlCm8/JImjPA8Rpg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdegledguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtugfgjgesthekredttddtjeenucfhrhhomheptehn ughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecugg ftrfgrthhtvghrnhephfeitefgleevtedtffejvedujeekjedugfdtveffjeelvddtfeek gefgjefhgfegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jan 2024 14:11:40 -0500 (EST) Date: Fri, 5 Jan 2024 11:11:39 -0800 From: Andres Freund To: Robert Haas Cc: Andy Fan , PostgreSQL Hackers , Thomas Munro Subject: Re: the s_lock_stuck on perform_spin_delay Message-ID: <20240105191139.djeez5zdr6ehvs73@awork3.anarazel.de> References: <87plyhvama.fsf@163.com> <20240104230628.j2wqqck3wrgol6ym@awork3.anarazel.de> 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: Archived-At: Precedence: bulk Hi, On 2024-01-05 08:51:53 -0500, Robert Haas wrote: > On Thu, Jan 4, 2024 at 6:06 PM Andres Freund wrote: > > 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. > > I mean +1 for the infrastructure, but "completely non-viable"? Why? > > I've only very rarely seen this PANIC occur, and in the few cases > where I've seen it, it was entirely unclear that the problem was due > to a bug where somebody failed to release a spinlock. I see it fairly regularly. Including finding several related bugs that lead to stuck systems last year (signal handlers are a menace). > It seemed more likely that the machine was just not really functioning, and > the PANIC was a symptom of processes not getting scheduled rather than a PG > bug. If processes don't get scheduled for that long a crash-restart doesn't seem that bad anymore :) > And every time I tell a user that they might need to use a debugger to, say, > set VacuumCostActive = false, or to get a backtrace, or any other reason, I > have to tell them to make sure to detach the debugger in under 60 seconds, > because in the unlikely event that they attach while the process is holding > a spinlock, failure to detach in under 60 seconds will take their production > system down for no reason. Hm - isn't the stuck lock timeout more like 900s (MAX_DELAY_USEC * NUM_DELAYS = 1000s, but we start at a lower delay)? One issue with the code as-is is that interrupted sleeps count towards to the timeout, despite possibly sleeping much shorter. We should probably fix that, and also report the time the lock was stuck for in s_lock_stuck(). > Now, if you're about to say that people shouldn't need to use a debugger on > their production instance, I entirely agree ... but in the world I inhabit, > that's often the only way to solve a customer problem, and it probably will > continue to be until we have much better ways of getting backtraces without > using a debugger than is currently the case. > > Have you seen real cases where this PANIC prevents a hangup? If yes, > that PANIC traced back to a bug in PostgreSQL? And why didn't the user > just keep hitting the same bug over and PANICing in an endless loop? Many, as hinted above. Some bugs in postgres, more bugs in extensions. IME these bugs aren't hit commonly, so a crash-restart at least allows to hobble along. The big issue with not crash-restarting is that often the system ends up inaccessible, which makes it very hard to investigate the issue. > I feel like this is one of those things that has just been this way > forever and we don't question it because it's become an article of > faith that it's something we have to have. But I have a very hard time > explaining why it's even a net positive, let alone the unquestionable > good that you seem to think. I don't think it's an unquestionable good, I just think the alternative of just endlessly spinning is way worse. Greetings, Andres Freund