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 1lqgaC-0006z3-BV for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jun 2021 18:36:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqgaB-0005bN-2R for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jun 2021 18:36:11 +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 1lqgaA-0005bF-NV for pgsql-hackers@lists.postgresql.org; Tue, 08 Jun 2021 18:36:10 +0000 Received: from smtp-fw-80006.amazon.com ([99.78.197.217]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqga5-0006QT-SA for pgsql-hackers@postgresql.org; Tue, 08 Jun 2021 18:36:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1623177366; x=1654713366; h=to:cc:references:from:message-id:date:mime-version: in-reply-to:subject; bh=6LO6KzUDOZAHmDcBJxztE+y26EfHFK/qc22iMs9rVyI=; b=N5kteDPKj1yF3Envde/IHdKkxbC6RimkGe5inJpIJLSJwmOskkNHCAyz 1sieD6GYWwIwhF47/a/UdPvMP+d7w+nhmAGg2/rjQMLZ1Z2mk9Q9cvFpG KB9vqJtARRCsg33Gc/wiSapQRh5AtxFfaT9qVkcYiJjlfpM1CW1Fcvt3k 8=; X-IronPort-AV: E=Sophos;i="5.83,259,1616457600"; d="scan'208,217";a="5599697" Subject: Re: logical decoding bug: segfault in ReorderBufferToastReplace() Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-1d-98acfc19.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP; 08 Jun 2021 18:36:02 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-98acfc19.us-east-1.amazon.com (Postfix) with ESMTPS id E2E3DA1FDB; Tue, 8 Jun 2021 18:35:59 +0000 (UTC) Received: from EX13D18UWA002.ant.amazon.com (10.43.160.199) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 8 Jun 2021 18:35:59 +0000 Received: from 186590ce269b.ant.amazon.com (10.43.162.144) by EX13D18UWA002.ant.amazon.com (10.43.160.199) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 8 Jun 2021 18:35:58 +0000 To: Amit Kapila , Alvaro Herrera CC: Andres Freund , "Drouvot, Bertrand" , Tomas Vondra , PostgreSQL-development References: <202106042335.o64q6dui5hu2@alvherre.pgsql> From: Jeremy Schneider Message-ID: <444215b4-8fb5-6a82-a534-645abafbffb4@amazon.com> Date: Tue, 8 Jun 2021 11:35:57 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------C824EC3AE6E8CA5E272A6A48" Content-Language: en-US X-Originating-IP: [10.43.162.144] X-ClientProxiedBy: EX13D28UWB001.ant.amazon.com (10.43.161.98) To EX13D18UWA002.ant.amazon.com (10.43.160.199) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --------------C824EC3AE6E8CA5E272A6A48 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 6/4/21 23:42, Amit Kapila wrote: > On 2021-Jun-04, Jeremy Schneider wrote: >>> ERROR: XX000: could not open relation with OID 0 >>> LOCATION: ReorderBufferToastReplace, reorderbuffer.c:305 > Even, if this fixes the issue, I guess it is better to find why this > happens? I think the reason why the code is giving an error is that > after toast insertions we always expect the insert on the main table > of toast table, but if there happens to be a case where after toast > insertion, instead of getting the insertion on the main table we get > an insert in some other table then you will see this error. I think > this can happen for speculative insertions where insertions lead to a > toast table insert, then we get a speculative abort record, and then > insertion on some other table. The main thing is currently decoding > code ignores speculative aborts due to which such a problem can occur. > Now, there could be other cases where such a problem can happen but if > my theory is correct then the patch we are discussing in the thread > [1] should solve this problem. > > Jeremy, is this problem reproducible? Can we get a testcase or > pg_waldump output of previous WAL records? > > [1] - https://www.postgresql.org/message-id/CAExHW5sPKF-Oovx_qZe4p5oM6Dvof7_P%2BXgsNAViug15Fm99jA%40mail.gmail.com It's unclear to me whether or not we'll be able to catch the repro on the actual production system. It seems that we are hitting this somewhat consistently, but at irregular and infrequent intervals. If we are able to catch it and walk the WAL records then I'll post back here. FYI, Bertrand was able to replicate the exact error message with pretty much the same repro that's in the other email thread which is linked above. Separately, would there be any harm in adding the relation OID to the error message? Personally, I just think the error message is generally more useful if it shows the main relation OID (since we know that the toast OID can be 0). Not a big deal though. -Jeremy -- Jeremy Schneider Database Engineer Amazon Web Services --------------C824EC3AE6E8CA5E272A6A48 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit
On 6/4/21 23:42, Amit Kapila wrote:
On 2021-Jun-04, Jeremy Schneider wrote:
ERROR: XX000: could not open relation with OID 0
LOCATION: ReorderBufferToastReplace, reorderbuffer.c:305
Even, if this fixes the issue, I guess it is better to find why this
happens? I think the reason why the code is giving an error is that
after toast insertions we always expect the insert on the main table
of toast table, but if there happens to be a case where after toast
insertion, instead of getting the insertion on the main table we get
an insert in some other table then you will see this error. I think
this can happen for speculative insertions where insertions lead to a
toast table insert, then we get a speculative abort record, and then
insertion on some other table. The main thing is currently decoding
code ignores speculative aborts due to which such a problem can occur.
Now, there could be other cases where such a problem can happen but if
my theory is correct then the patch we are discussing in the thread
[1] should solve this problem.

Jeremy, is this problem reproducible? Can we get a testcase or
pg_waldump output of previous WAL records?

[1] - https://www.postgresql.org/message-id/CAExHW5sPKF-Oovx_qZe4p5oM6Dvof7_P%2BXgsNAViug15Fm99jA%40mail.gmail.com

It's unclear to me whether or not we'll be able to catch the repro on the actual production system. It seems that we are hitting this somewhat consistently, but at irregular and infrequent intervals. If we are able to catch it and walk the WAL records then I'll post back here. FYI, Bertrand was able to replicate the exact error message with pretty much the same repro that's in the other email thread which is linked above.

Separately, would there be any harm in adding the relation OID to the error message? Personally, I just think the error message is generally more useful if it shows the main relation OID (since we know that the toast OID can be 0). Not a big deal though.

-Jeremy


-- 
Jeremy Schneider
Database Engineer
Amazon Web Services
--------------C824EC3AE6E8CA5E272A6A48--