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 1nf2jp-00037a-0x for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Apr 2022 16:54:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nf2jn-00045k-V3 for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Apr 2022 16:54:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nf2jn-00045b-LM for pgsql-hackers@lists.postgresql.org; Thu, 14 Apr 2022 16:54:31 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nf2jl-0005kV-KB for pgsql-hackers@lists.postgresql.org; Thu, 14 Apr 2022 16:54:31 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8DE8E5C0249; Thu, 14 Apr 2022 12:54:27 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 14 Apr 2022 12:54:27 -0400 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=fm1; t=1649955267; x=1650041667; bh=ISSI94es0N Uv3QBkY8Ct3FUBwbaQG33mX1eGEad+tvQ=; b=P+GzH10EaPOqT4PNlCAUTJ3NuD hhMuD0MnOEoDgOl4VCkE14C30HHayxjKY5ILkIdN1sCNGEZLvQTEOnnR1Jjkp0h/ 27jV3WQqBqih6NptP2Bd09vdR7I4O4lELOHiyURCcMd7nOx9mG1nTvEns3+deEko Qo2/CA7k4iW8af/P2EIYTjJ90J7rur5jHySYawNlQ+pnDbl+glFZko5d+gn8e55y DkkrAwHXgd6Amnj53c0KPlxg7EXdzN2qe+U81saDA0hR2kbRy2OoYS9PG09OFWC5 Z8NU/xgZJ2Z7K+KGGKcEnt8Yq97QKblFl9G5TAjVyaIHmOfYqT99PpFAY4uA== 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; t=1649955267; x= 1650041667; bh=ISSI94es0NUv3QBkY8Ct3FUBwbaQG33mX1eGEad+tvQ=; b=B mmddKDc7bGzzVrCovbEoT9OG1S8KtHyRr1KBn32qkkv96CJoS5HxVu0F+TgMbKa5 s/BbbkffkAKxhscMFcpeuAElv3C3AXoxGVnHbLPFqoj5UL2C8ptzQ1TLWQXzt5j8 jZynS+Ode0m3n1CkDlN4L3P4MlthG4FoRDyPxDO8aBk84tJ5AvAbdzecLtLZ/Rob ckXgIBMbrLulejkEQ93fkneNuaKs6bGzptcb381TT9q6nHWPKLuAlBabA+7f/Idn vpOk6bI5mVDx92rfSssExvD5/+bZDTOgvF5Et7hRJXhNVCo1l8ZWLlIkFli0rT8h biINOqKnkFd+QnyjgXKXQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudelfedguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeff hfeuffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 14 Apr 2022 12:54:26 -0400 (EDT) Date: Thu, 14 Apr 2022 09:54:25 -0700 From: Andres Freund To: Robert Haas Cc: Tom Lane , Justin Pryzby , Kyotaro Horiguchi , Erik Rijkers , Matthias van de Meent , PostgreSQL Hackers Subject: Re: TRAP: FailedAssertion("HaveRegisteredOrActiveSnapshot()", File: "toast_internals.c", Line: 670, PID: 19403) Message-ID: <20220414165425.pxn22hdlwdrcouh6@alap3.anarazel.de> References: <20220330.100617.1491348930290941094.horikyota.ntt@gmail.com> <20220330.114613.1177577626285014184.horikyota.ntt@gmail.com> <20220330.175824.936439875658680065.horikyota.ntt@gmail.com> <20220413202819.GR26620@telsasoft.com> <20220414003802.e37dgzkgbi5t7ha4@alap3.anarazel.de> <1471620.1649947373@sss.pgh.pa.us> <1484483.1649951206@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-04-14 12:16:45 -0400, Robert Haas wrote: > I got curious and looked at the underlying problem here and I am > wondering whether HaveRegisteredOrActiveSnapshot() is just buggy. It > seems to me that the code is always going to return true if there are > any active snapshots, and the rest of the function is intended to test > whether there is a registered snapshot other than the catalog > snapshot. But I don't think that's what this code does: > > if (pairingheap_is_empty(&RegisteredSnapshots) || > !pairingheap_is_singular(&RegisteredSnapshots)) > return false; > > return CatalogSnapshot == NULL; Certainly looks off... > I find that 'make check-world' passes with this change, which is > disturbing, because it also passes without this change. That means we > don't have any tests that reach HaveRegisteredOrActiveSnapshot() with > more than one registered snapshot. Part of that is because right now the assertion is placed "too deep" - it should be much higher up, so it's reached even if there's not actually a toast datum. But there's of other bugs preventing that :(. A lot of bugs have been hidden by the existence of CatalogSnapshot (which of course isn't something one actually can rely on). > Also, unless we have plans to use HaveRegisteredOrActiveSnapshot() in > more places, I think we should, but there's the other bugs that need to be fixed first :(. Namely that we have plenty places doing catalog accesses without an active or registered snapshot :(. > I think we should consider revising the whole approach here. The way > init_toast_snapshot() is coded, we basically have some code that tests > for active and registered snapshots and finds the oldest one. We error > out if there isn't one. And then we get to this assertion, which > checks the same stuff a second time but with an additional check to > see whether we ended up with the catalog snapshot. Wouldn't it make > more sense if GetOldestSnapshot() just refused to return the catalog > snapshot in the first place? I'm worried that that could cause additional bugs. Consider code using GetOldestSnapshot() to check if tuples need to be preserved or such. Greetings, Andres Freund