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 1lz7wZ-0007Bx-Cs for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Jul 2021 01:26:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lz7wX-00066T-9X for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Jul 2021 01:26:09 +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 1lz7wX-00066L-0B for pgsql-hackers@lists.postgresql.org; Fri, 02 Jul 2021 01:26:09 +0000 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lz7wQ-0000iy-Ff for pgsql-hackers@postgresql.org; Fri, 02 Jul 2021 01:26:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1625189162; x=1656725162; h=from:subject:to:message-id:date:mime-version; bh=k7dHQjucXP3xgJc0l81NRwc97wyB1MABAyU6jTm/cA0=; b=rrS35jBVTKfb95P7YWBcSRciWcP1Uf/xMFUWqO5KxyVqhPoju5rrUh38 2ZxzAFAdNe80QLQKHFedBrP5FQENX06mFAB/gutuaj8MywdAk6LG8f/53 tnldn+V5IMB+Cs+z1FEZKfWi985ruFufaYnBX79e+6wMXUO5N/WogEbKh U=; X-IronPort-AV: E=Sophos;i="5.83,316,1616457600"; d="scan'208,217";a="134063134" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP; 02 Jul 2021 01:26:00 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com (Postfix) with ESMTPS id 32D13282662 for ; Fri, 2 Jul 2021 01:25:59 +0000 (UTC) Received: from EX13D18UWA002.ant.amazon.com (10.43.160.199) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 2 Jul 2021 01:25:59 +0000 Received: from 186590ce269b.ant.amazon.com (10.43.160.41) by EX13D18UWA002.ant.amazon.com (10.43.160.199) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 2 Jul 2021 01:25:59 +0000 From: Jeremy Schneider Subject: relation OID in ReorderBufferToastReplace error message To: PostgreSQL-development Message-ID: <808ed65b-994c-915a-361c-577f088b837f@amazon.com> Date: Thu, 1 Jul 2021 18:25:58 -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 Content-Type: multipart/alternative; boundary="------------2457D201911B64A404FDB7A6" Content-Language: en-US X-Originating-IP: [10.43.160.41] X-ClientProxiedBy: EX13D11UWC003.ant.amazon.com (10.43.162.162) 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 --------------2457D201911B64A404FDB7A6 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit I've recently been working with a PostgreSQL database where we saw ReorderBufferToastReplace() fail due to a reltoastrelid value of 0.  In the original thread, Amit pointed out a connection to the speculative insert decoding memory leak bug.  Bertrand built a test case confirming that a speculative abort record followed by an insert on another table would in fact produce the error message from ReorderBufferToastReplace() that we had seen, and accordingly we're pretty sure that was the root cause in this particular database. https://www.postgresql.org/message-id/5f9a118e-86c5-d4f1-b584-199a33757cd4%40amazon.com Nonetheless, in the process of troubleshooting it occurred to me that this error message would be more useful in general if it included the base relation OID in the error message. Amit suggested a separate thread - so here we are.  :) https://www.postgresql.org/message-id/CAA4eK1%2BdeBBnMVPxfLuv1Aa7tuh-7e3FvnSvWTaCy4-_HPcBLg%40mail.gmail.com Anyone have thoughts?  Would I need a commitfest entry to propose a two-line tweak like this? -Jeremy diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 2d9e1279bb..b90603b051 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -4598,8 +4598,8 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,         toast_rel = RelationIdGetRelation(relation->rd_rel->reltoastrelid);         if (!RelationIsValid(toast_rel)) -               elog(ERROR, "could not open relation with OID %u", -                        relation->rd_rel->reltoastrelid); +               elog(ERROR, "could not open toast relation with OID %u (base relation with OID %u)", +                        relation->rd_rel->reltoastrelid, relation->rd_rel->oid);         toast_desc = RelationGetDescr(toast_rel); -- Jeremy Schneider Database Engineer Amazon Web Services --------------2457D201911B64A404FDB7A6 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit I've recently been working with a PostgreSQL database where we saw ReorderBufferToastReplace() fail due to a reltoastrelid value of 0.  In the original thread, Amit pointed out a connection to the speculative insert decoding memory leak bug.  Bertrand built a test case confirming that a speculative abort record followed by an insert on another table would in fact produce the error message from ReorderBufferToastReplace() that we had seen, and accordingly we're pretty sure that was the root cause in this particular database.

https://www.postgresql.org/message-id/5f9a118e-86c5-d4f1-b584-199a33757cd4%40amazon.com

Nonetheless, in the process of troubleshooting it occurred to me that this error message would be more useful in general if it included the base relation OID in the error message. Amit suggested a separate thread - so here we are.  :)

https://www.postgresql.org/message-id/CAA4eK1%2BdeBBnMVPxfLuv1Aa7tuh-7e3FvnSvWTaCy4-_HPcBLg%40mail.gmail.com

Anyone have thoughts?  Would I need a commitfest entry to propose a two-line tweak like this?

-Jeremy



diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 2d9e1279bb..b90603b051 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -4598,8 +4598,8 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,

        toast_rel = RelationIdGetRelation(relation->rd_rel->reltoastrelid);
        if (!RelationIsValid(toast_rel))
-               elog(ERROR, "could not open relation with OID %u",
-                        relation->rd_rel->reltoastrelid);
+               elog(ERROR, "could not open toast relation with OID %u (base relation with OID %u)",
+                        relation->rd_rel->reltoastrelid, relation->rd_rel->oid);

        toast_desc = RelationGetDescr(toast_rel);



-- 
Jeremy Schneider
Database Engineer
Amazon Web Services
--------------2457D201911B64A404FDB7A6--