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 1mlGK3-0001JW-KN for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Nov 2021 20:05:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mlGK2-0003d0-KV for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Nov 2021 20:05:22 +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 1mlGK2-0003cq-CH for pgsql-bugs@lists.postgresql.org; Thu, 11 Nov 2021 20:05:22 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlGJz-0002nD-VE for pgsql-bugs@lists.postgresql.org; Thu, 11 Nov 2021 20:05:21 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id D65DF3202405; Thu, 11 Nov 2021 15:05:18 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 11 Nov 2021 15:05:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=rMX2cL2gn7WVF68Ayfge6ndMkbT KhFbd+2M+1VsBQDw=; b=hAGn+SLT/MbsgO1HrAhX9DS9zibtMo+JUvtrAI3XyxV sjSKFMJI0inzleFoOb0TS3Wvb5bReT/K9YFvCJWUGoRbxIpb5kofNqV2CyvyXC7l 24A/hvn+qH49KpU0TsBHD89qT5oV5/bZkD/c/MhGrIH1cvzSMLnzxsL3aIBe6kFd WWyGerFJR9hvtZNUi8X28W9b6elMdFM6f0D+viBCN0C4dBl/ggx/ygd82tUQ/xo4 IjhSNS/tDaRHV9tAMf+NkuGmFbxpmwP1UNHkA/Ya1CS6vCf0An24h+rdmbJbi8R6 nPtXUQWFgc5OlUraPQTWdkPMFb2Gtyoqnetud85ogmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=rMX2cL 2gn7WVF68Ayfge6ndMkbTKhFbd+2M+1VsBQDw=; b=bOi1ES0LkYA+CrtJ7mrK50 dZM/5bLwO8EWJNXW4QOmpYl0EnhZr5Bs5xDzrsvk4rLL5OSDNd7O3xAK9gvpABX0 5zzRWUYhQggQQJXUNdvhX5BfNEtgUplngfU1Hf9XsFG+Tw+nPOOCZ1DSICdK2FDE unx+iETbGjBYSiMCgEZcWPafQElQKd2ZRI/Y3OFEDq0wyFMVetrIyri6MHJAmn83 JPx0SYgrNiwgPz1miM10jr8u79oJWYyuHPy87wg98jB4MLlQQQ0y8i4nm1GzUCrd FvzlW4fPBMnT+nI+GhQjDhAdSzgFCADZLVqZVi8loYmmvljvIka4IYFF7CgGguIA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrvddugddufedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedukefhkeelueegveetheelffffjeegleeuudelfeefuedtleffueejfffh ueffudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 Nov 2021 15:05:17 -0500 (EST) Date: Thu, 11 Nov 2021 12:05:17 -0800 From: Andres Freund To: Peter Geoghegan Cc: Dmitry Dolgov <9erthalion6@gmail.com>, Alexander Lakhin , Matthias van de Meent , PostgreSQL mailing lists Subject: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum Message-ID: <20211111200517.fcg342s5mirwdacc@alap3.anarazel.de> References: <20211110192010.ckvfzz352hsba5xf@alap3.anarazel.de> <20211111004727.imn7xrimdiyo7vfv@alap3.anarazel.de> <20211111021618.n5ebam6f6licj746@alap3.anarazel.de> <20211111031641.kqj4w64klqt7ta2h@alap3.anarazel.de> 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 2021-11-10 19:33:01 -0800, Peter Geoghegan wrote: > On Wed, Nov 10, 2021 at 7:16 PM Andres Freund wrote: > > We can't really do the same with the > > hard horizons. It's currently super likely that the horizon moves forward a > > lot between vacuum_set_xid_limits() and GlobalVisTestFor(), but moving it > > closer still is going in the wrong direction. > > ...why is that super likely? I have to admit that I have no idea what > you mean by that. Err, I missed a *not* in there, sorry for the confusion. > > So I'm inclined to add a comment saying that we need to do the > > GlobalVisTestFor(), pointing to the comment in ComputeXidHorizons(), and > > adding a TODO that we should find a heuristic when to recompute horizons? > > Okay. Even still, I suggest that you say something about this new > DELETE_IN_PROGRESS pruning behavior in vacuumlazy.c. Maybe in > lazy_scan_prune()? That doesn't quite make sense to me. There's quite a few ways that a HTSV can change for the same tuple, and listing them all in vacuumlazy.c doesn't really help people notice that when they add a new call or such. There's plenty other callsites - like the one in heap_prune_chain()... How about changing the comment above lazy_scan_prune() to note that the concurrent abort case is one example of this behaviour? And then add a comment to HeapTupleSatisfiesVacuum() along the lines of: NB: Repeated calls to HeapTupleSatisfiesVacuum for the same tuple may change even while the buffer is locked. Cases of this include: - the transaction that inserted a tuple (version) aborted, changing the result from HEAPTUPLE_INSERT_IN_PROGRESS to HEAPTUPLE_DEAD - when used with GlobalVisTestIsRemovableXid(), HEAPTUPLE_DELETE_IN_PROGRESS can change to HEAPTUPLE_DEAD if the horizon is updated However, HEAPTUPLE_DEAD will not change back to HEAPTUPLE_RECENTLY_DEAD or such. > > > We could probably *also* freeze tuples opportunistically (e.g., freeze > > > a few tuples on a page early to be able to mark it all-frozen sooner), > > > > We should definitely do that when a page is already being dirtied for other > > reasons. > > Agreed. But at the very least we should be thinking about the > whole-page picture. If we made freezing a whole page cheap enough > (smaller WAL records), then maybe the separate all-visible state > becomes totally unnecessary (except for pg_upgrade). I doubt it. But I think getting rid of unnecessarily dirtying the page a second (or third) time would be a big enough win already... Greetings, Andres Freund