Re: relation OID in ReorderBufferToastReplace error message

From: Jeremy Schneider <schnjere(at)amazon(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: relation OID in ReorderBufferToastReplace error message
Date: 2021-07-03 01:57:37
Message-ID: abc2552c-acd0-ecd3-0bd9-1b398be29cbf@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-07-03 04:24:57 Re: logical replication worker accesses catalogs in error context callback
Previous Message Noah Misch 2021-07-03 00:16:39 Re: Preventing abort() and exit() calls in libpq