Re: logicalrep_message_type throws an error

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: Euler Taveira <euler(at)eulerto(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Subject: Re: logicalrep_message_type throws an error
Date: 2023-07-06 09:30:27
Message-ID: CAA4eK1J9BWifu_7y9MeUw2sMUsRC+d_6WBV1uF5Db18iPH6RPg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 5, 2023 at 7:54 PM Ashutosh Bapat
<ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
>
> On Wed, Jul 5, 2023 at 7:07 PM Euler Taveira <euler(at)eulerto(dot)com> wrote:
> >
> > On Wed, Jul 5, 2023, at 7:56 AM, Alvaro Herrera wrote:
> >
> > On 2023-Jul-05, Amit Kapila wrote:
> >
> > > I think after returning "???" from logicalrep_message_type(), the
> > > above is possible when we get the error: "invalid logical replication
> > > message type "X"" from apply_dispatch(), right? If so, then what about
> > > the case when we forgot to handle some message in
> > > logicalrep_message_type() but handled it in apply_dispatch()?
>
> apply_dispatch() has a default case in switch() so it can
> theoretically forget to handle some message type. I think we should
> avoid default case in that function to catch missing message type in
> that function. But if logicalrep_message_type() doesn't use default
> case, it won't forget to handle a known message type. So what you are
> suggesting is not possible.
>

Right, but still I feel it would be better to return actual action.

> It might happen that the upstream may send an unknown message type
> that both apply_dispatch() and logicalrep_message_type() can not
> handle.
>
> > ERROR: invalid logical replication message type "X"
> > CONTEXT: processing remote data for replication origin "pg_16638" during message type "??? (88)" in transaction 796, finished at 0/1626698
> >
> > IMO it could be confusing if we provide two representations of the same data (X
> > and 88). Since we already provide "X" I don't think we need "88". Another
> > option, is to remove "X" from apply_dispatch() and add "??? (88)" to
> > logicalrep_message_type().
>
> I think we don't need message type to be mentioned in the context for
> an error about invalid message type. I think what needs to be done is
> to set
> apply_error_callback_arg.command = 0 before calling ereport in the
> default case of apply_dispatch().
> apply_error_callback() will just return without providing a context.
>

Hmm, this looks a bit hacky to me.

--
With Regards,
Amit Kapila.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-07-06 09:32:32 Re: EBCDIC sorting as a use case for ICU rules
Previous Message Amit Kapila 2023-07-06 09:28:42 Re: logicalrep_message_type throws an error