relation OID in ReorderBufferToastReplace error message - Mailing list pgsql-hackers

From Jeremy Schneider
Subject relation OID in ReorderBufferToastReplace error message
Date
Msg-id 808ed65b-994c-915a-361c-577f088b837f@amazon.com
Whole thread Raw
Responses Re: relation OID in ReorderBufferToastReplace error message  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: cutting down the TODO list thread
Next
From: Michael Paquier
Date:
Subject: Re: Can a child process detect postmaster death when in pg_usleep?