Re: relation OID in ReorderBufferToastReplace error message

Jeremy Schneider <schnjere@amazon.com>

From: Jeremy Schneider <schnjere@amazon.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2021-07-03T01:57:37Z
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

Commits

  1. Back-patch "Add parent table name in an error in reorderbuffer.c."

  2. Add parent table name in an error in reorderbuffer.c.

  3. Fix reorder buffer memory accounting for toast changes.

  4. Add logical change details to logical replication worker errcontext.

  5. Fix toast rewrites in logical decoding.

  6. Add error codes to some corruption log messages