Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiRaZ-0007hf-1a for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2019 23:21:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iiRaX-0001x6-GB for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2019 23:21:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiRaW-0001wv-Q6; Fri, 20 Dec 2019 23:21:41 +0000 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iiRaP-00030X-MD; Fri, 20 Dec 2019 23:21:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1576884094; x=1608420094; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=TrmdU0qYOEMzMyI7YolwwfZbh0u3Mf5YdkRj+rOzX2c=; b=cq+hGcLBS86at+reSA9Q6mXqnjAqhNhnaXO6FTCpZ01uOU/BcR9MeifB mdADNf/VdHPByX02gYhA4VwGEAG/XX2xKEFcY4fycGwaaNJFs69VvBdPo 52pzJCU2tLjtlCrh4Bpe/VDELtX3t3janLth1dEqe+WwIEdSmE5Zk1JiQ 8=; IronPort-SDR: U4pNIYRSbQmdVBf4a6qMx55azEAUUipQRM/0PThzYLdmyj+SeTDNh/AZP5ZHNT1S/oSi2ROadN PYhbU2vWu8Rw== X-IronPort-AV: E=Sophos;i="5.69,337,1571702400"; d="scan'208";a="10027318" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 20 Dec 2019 23:21:33 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (Postfix) with ESMTPS id E595A241AB0; Fri, 20 Dec 2019 23:21:31 +0000 (UTC) Received: from EX13D18UWA002.ant.amazon.com (10.43.160.199) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 20 Dec 2019 23:21:31 +0000 Received: from 186590ce269b.ant.amazon.com (10.43.160.109) by EX13D18UWA002.ant.amazon.com (10.43.160.199) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 20 Dec 2019 23:21:31 +0000 Subject: Re: logical decoding bug: segfault in ReorderBufferToastReplace() To: Andres Freund CC: "Drouvot, Bertrand" , Tomas Vondra , "pgsql-bugs@postgresql.org" , PostgreSQL-development References: <20191205133836.lulisfo2fphdrjp3@development> <20191211163522.t2ljtydarlmusoix@alap3.anarazel.de> <81182626-e836-061f-8f19-204edac18922@amazon.com> <20191214002513.p5rw6vqenzvrud5y@alap3.anarazel.de> From: Jeremy Schneider Message-ID: <187dfed1-7d97-4a8c-2932-b8a3d4dce697@amazon.com> Date: Fri, 20 Dec 2019 15:21:30 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191214002513.p5rw6vqenzvrud5y@alap3.anarazel.de> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.43.160.109] X-ClientProxiedBy: EX13D16UWC003.ant.amazon.com (10.43.162.15) To EX13D18UWA002.ant.amazon.com (10.43.160.199) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/13/19 16:25, Andres Freund wrote: > On 2019-12-13 16:13:35 -0800, Jeremy Schneider wrote: >> On 12/11/19 08:35, Andres Freund wrote: >>> I think we need to see pg_waldump output for the preceding records. That >>> might allow us to see why there's a toast record that's being associated >>> with this table, despite there not being a toast table. >> Unfortunately the WAL logs are no longer available at this time.  :( >> >> I did a little poking around in the core file and searching source code >> but didn't find anything yet.  Is there any memory structure that would >> have the preceding/following records cached in memory?  If so then I >> might be able to extract this from the core dumps. > > Well, not the records directly, but the changes could be, depending on > the size of the changes. That'd already help. It depends a bit on > whether there are subtransactions or not (txn->nsubtxns will tell > you). Within one transaction, the currently loaded (i.e. not changes > that are spilled to disk, and haven't currently been restored - see > txn->serialized) changes are in ReorderBufferTXN->changes. I did include the txn in the original post to this thread; there are 357 changes in the transaction and they are all in memory (none spilled to disk a.k.a. serialized). No subtransactions. However I do see that "txn.has_catalog_changes = true" which makes me wonder if that's related to the bug. So... now I know... walking a dlist in gdb and dumping all the changes is not exactly a walk in the park! Need some python magic like Tomas Vondra's script that decodes Nodes. I was not yet successful today in figuring out how to do this... so the changes are there in the core dump but I can't get them yet. :) I also dug around the ReorderBufferIterTXNState a little bit but there's nothing that isn't already in the original post. If anyone has a trick for walking a dlist in gdb that would be awesome... I'm off for holidays and won't be working on this for a couple weeks; not sure whether it'll be possible to get to the bottom of it. But I hope there's enough info in this thread to at least get a head start if someone hits it again in the future. > Well, I've heard mutterings that plain RDS postgres had some efficiency > improvements around snapshots (in the GetSnapshotData() sense) - and > that's an area where slightly wrong changes could quite plausibly > cause a bug like this. Definitely no changes around snapshots. I've never even heard anyone talk about making changes like that in RDS PostgreSQL - feels to me like people at AWS want it to be as close as possible to postgresql.org code. Aurora is different; it feels to me like the engineering org has more license to make changes. For example they re-wrote the subtransaction subsystem. No changes to GetSnapshotData though. -Jeremy -- Jeremy Schneider Database Engineer Amazon Web Services