Re: logical decoding bug: segfault in ReorderBufferToastReplace()

From: Jeremy Schneider <schnjere(at)amazon(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: logical decoding bug: segfault in ReorderBufferToastReplace()
Date: 2021-06-04 23:07:02
Message-ID: c41e5883-aedf-7944-010e-0b48b6c677ba@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-committers pgsql-hackers

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2021-06-04 23:35:33 Re: logical decoding bug: segfault in ReorderBufferToastReplace()
Previous Message PG Bug reporting form 2021-06-04 22:46:48 BUG #17048: about trace_locks parameter problem

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2021-06-04 23:35:33 Re: logical decoding bug: segfault in ReorderBufferToastReplace()
Previous Message David Rowley 2021-06-04 11:40:12 pgsql: Doc: Fix some spelling mistakes

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2021-06-04 23:14:21 Re: Table AM modifications to accept column projection lists
Previous Message Oh, Mike 2021-06-04 22:59:22 Re: [BUG] Logical replication failure "ERROR: could not map filenode "base/13237/442428" to relation OID" with catalog modifying txns