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 1pmM88-0004VM-TQ for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Apr 2023 22:06:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pmM87-0006Jp-6r for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Apr 2023 22:06:23 +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 1pmM51-0000Bs-Sa for pgsql-hackers@lists.postgresql.org; Tue, 11 Apr 2023 22:03:12 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pmM4y-002JcE-8Y for pgsql-hackers@lists.postgresql.org; Tue, 11 Apr 2023 22:03:11 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B1839320096E; Tue, 11 Apr 2023 18:03:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 11 Apr 2023 18:03:04 -0400 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:sender :subject:subject:to:to; s=fm3; t=1681250584; x=1681336984; bh=9D sPNC1FL5GYiA8/J1koIrhOIhkCA5qvYXReVTeaITE=; b=DWcm7XUv9CI/iFuc1q U54DRJ1EAXhy7OXWPd+wILSAl5z431v3J1W3m3etISOHCtsELlnt/kquL8hrR3ju yi34OgC1/5OirBzUNwB/M/a2gMth886Ys0uvjcU3+BQX6kpxMVkWSpG78ROxcNuq +jS8Wrek24Dm4Dnk8o8M9Rrr7sBW9VoOmX6lbQjIWiyCgtPn8E354j/rrgsJ9RnK DVVTQFqAT6flBEjnDDbQjhRm4Ggq9PJWJYbP0o+v/AjflLBzfyPT+dGA03aovBMD qeygEPF6irxEe/y4V6O4UWzw1B1ycnFK3a2ZUAvdUHI3iuRYPqkvQf7dZ741hScy qnkQ== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1681250584; x=1681336984; bh=9DsPNC1FL5GYi A8/J1koIrhOIhkCA5qvYXReVTeaITE=; b=PHphsgyw4hDSwPkEpQyJM+Qo3IVeG qlmTrSP7KS8qXnJR76FuF8mNenNQ8lWYE+mPTw7iBov7Kzx4it+J7+jUxS8GVYzc 5what+MGRu9Q3qGQaZrx5kUJCjUsW/o2yjXvnNKEk1yXGtek0NYytDCZakJpCE7U aX8hiZcxNSM8Kcf32gyMCORKqVznOKWr9w5xaxsyF8/QnqfweyK/QDWqllKVW4qK dXTn+gV5TwrT2Epgq/CrRxUO6Af0FFnb66fTJyghJO//lc2BFKXKOEh1nn2rGdhZ 9hVxZluCbP4uc0KgFn/EYzLC6164b3EwI6e7CPirfFAdamogNKXiuFvDg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekhedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehttd ertddttddvnecuhfhrohhmpeetnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegr nhgrrhgriigvlhdruggvqeenucggtffrrghtthgvrhhnpedvffefvefhteevffegieetfe fhtddvffejvefhueetgeeludehteevudeitedtudenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 11 Apr 2023 18:03:03 -0400 (EDT) Date: Tue, 11 Apr 2023 15:03:02 -0700 From: Andres Freund To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Assertion being hit during WAL replay Message-ID: <20230411220302.vzikb3tustz7lvqw@awork3.anarazel.de> References: <392271.1681238924@sss.pgh.pa.us> <20230411195624.q3woyzoe5ediz43i@awork3.anarazel.de> <529161.1681246493@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <529161.1681246493@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2023-04-11 16:54:53 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2023-04-11 14:48:44 -0400, Tom Lane wrote: > >> I have seen this failure a couple of times recently while > >> testing code that caused crashes and restarts: > > > Do you have a quick repro recipe? > > Here's something related to what I hit that time: > > diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c > index 052263aea6..d43a7c7bcb 100644 > --- a/src/backend/optimizer/plan/subselect.c > +++ b/src/backend/optimizer/plan/subselect.c > @@ -2188,6 +2188,7 @@ SS_charge_for_initplans(PlannerInfo *root, RelOptInfo *final_rel) > void > SS_attach_initplans(PlannerInfo *root, Plan *plan) > { > + Assert(root->init_plans == NIL); > plan->initPlan = root->init_plans; > } > > You won't get through initdb with this, but if you install this change > into a successfully init'd database and then "make installcheck-parallel", > it will crash and then fail to recover, at least a lot of the time. Ah, that allowed me to reproduce. Thanks. Took me a bit to understand how we actually get into this situation. A PRUNE record for relation+block that doesn't exist during recovery. That doesn't commonly happen outside of PITR or such, because we obviously need a block with content to generate the PRUNE. The way it does happen here, is that the relation is vacuumed and then truncated. Then we crash. Thus we end up with a PRUNE record for a block that doesn't exist on disk. Which is also why the test is quite timing sensitive. Seems like it'd be good to have a test that covers this scenario. There's plenty code around it that doesn't currently get exercised. None of the existing tests seem like a great fit. I guess it could be added to 013_crash_restart, but that really focuses on something else. So I guess I'll write a 036_notsureyet.pl... Greetings, Andres Freund