On 12/13/19 16:13, Jeremy Schneider wrote:
On 12/11/19 08:35, Andres Freund wrote:
Seems like we clearly should add an elog(ERROR) here, so we error out,
rather than crash.
done - in the commit that I replied to when I started this thread :)
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=69f883fef14a3fc5849126799278abcc43f40f56
Another PostgreSQL user ran into this issue. This time on version 12.5 - so instead of a crash they got the error message from the commit.
ERROR: XX000: could not open relation with OID 0
LOCATION: ReorderBufferToastReplace, reorderbuffer.c:305
Upon seeing this error message, I realized that the base relation OID would be very useful when the toast relation OID is "0".
Would this patch work to show that?
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);
Thoughts?
-Jeremy
--
Jeremy Schneider
Database Engineer
Amazon Web Services