Re: Add an option to skip loading missing publication to avoid logical replication failure

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add an option to skip loading missing publication to avoid logical replication failure
Date: 2025-03-13 09:50:01
Message-ID: CAA4eK1L-4c2+v7NZB4jWDwtN-VT+UKAm9Vp2dzO2Tyg0HTJvbQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 13, 2025 at 11:43 AM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> Looks fine, shall we add the missing publication point as well
> something like below
>
> /*
> * In operations like 'ALTER SUBSCRIPTION ... ADD/SET PUBLICATION' and
> * 'CREATE SUBSCRIPTION', if the specified publication does not exist or
> * if the replication origin is not updated before the worker exits,
> * the WAL start location may point to a position prior to the publication's
> * WAL record. This can cause persistent restarts and errors
> * in the apply worker.
> *

I think that is too much related to pub-sub model, and ideally,
pgoutput should not care about it. I have written a comment
considering somebody using pgoutput decoding module via APIs.

> > * Additionally, dropping a subscription's publication should not
> > * disrupt logical replication.
> *
> > * This ensures that a missing publication is skipped and loaded
> > * when its corresponding WAL record is encountered.
> */
>
>
>
> > ereport(WARNING,
> > errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> > errmsg("skipped loading publication: %s", pubname),
> > errhint("If the publication is missing, create and refresh it.
> > Otherwise, wait for the slot to reach the WAL record, then refresh"));
> >
> > > 2. + errhint("If the publication already exists, ignore it as it will
> > > be loaded upon reaching the corresponding WAL record; otherwise,
> > > create it."));
> > >
> > > Is this hint correct? This is a question rather than a comment: When
> > > we reach a particular WAL where the publication was created, will the
> > > publication automatically load, or does the user need to REFRESH the
> > > publications?
> >
> > Users need to refresh the publication in case the relation is not
> > already added to pg_subscription_rel and apply incremental changes.
> > How about an error hint like:
> > "If the publication is missing, create and refresh it. Otherwise, wait
> > for the slot to reach the WAL record for the created publication, then
> > refresh"
>

I have tried to split this information into errdetail and errhint in
the attached. See and let me know what you think of the same.

--
With Regards,
Amit Kapila.

Attachment Content-Type Size
v9-0001-Fix-ALTER-SUBSCRIPTION-.-SET-PUBLICATION-.-comman.patch application/octet-stream 5.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-03-13 09:54:28 Re: Changing the state of data checksums in a running cluster
Previous Message Kirill Reshke 2025-03-13 09:46:46 Re: PoC: Simplify recovery after dropping a table by LOGGING the restore LSN