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

From Jeremy Schneider
Subject Re: relation OID in ReorderBufferToastReplace error message
Date
Msg-id abc2552c-acd0-ecd3-0bd9-1b398be29cbf@amazon.com
Whole thread Raw
In response to Re: relation OID in ReorderBufferToastReplace error message  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: relation OID in ReorderBufferToastReplace error message  (Jeremy Schneider <schnjere@amazon.com>)
List pgsql-hackers
On 7/1/21 20:44, Tom Lane wrote:
So I think the relation name is what to print here.  That's generally
what we do, and there's not much argument for this case to be different.

Works for me.  Anything in the error message is quickly and easily visible to users, without attaching debuggers or decoding WAL. A lot of PostgreSQL users won't know how to do the advanced troubleshooting, but knowing the table name might give a clue for better identifying SQL that might have been related, and could help produce better bug reports to the mailing lists in the future.

Related to that, I do think it could be useful to backpatch this - we know that users are hitting this error on older versions.  Even though it's most likely that the speculative insert decoding memory leak bug will address the problem, this update still seems low-risk and useful to me just in the off-chance that someone hits the error again.

(I'm not unsympathetic to the idea that printing schema names
would be helpful.  Just that here is not where to start with
that.  Maybe we could consider sucking in the schema name
during relcache entry build, and then print from that copy so we
don't need an additional catalog fetch under error conditions?)

Agreed not to tackle that in this thread; I wouldn't want to slow down the simple tweak that could be useful.

-Jeremy


diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index b8c5e2a44e..6a3a35d05d 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -4625,8 +4625,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 \"%s\")",
+                        relation->rd_rel->reltoastrelid, relation->rd_rel->relname);

        toast_desc = RelationGetDescr(toast_rel);




-- 
Jeremy Schneider
Database Engineer
Amazon Web Services

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Preventing abort() and exit() calls in libpq
Next
From: Bharath Rupireddy
Date:
Subject: Re: logical replication worker accesses catalogs in error context callback