Re: Replication slot is not able to sync up

From: Amul Sul <sulamul(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Suraj Kharage <suraj(dot)kharage(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Replication slot is not able to sync up
Date: 2025-05-30 11:24:00
Message-ID: CAAJ_b95v3SqN+CyC9B=fPtF8i3m_YG-S6=yxevNqVVL-rSrJ3A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 30, 2025 at 4:32 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Fri, May 30, 2025 at 4:05 PM Amul Sul <sulamul(at)gmail(dot)com> wrote:
> >
> > Quick question -- due to my limited understanding of this area: why
> > can't we perform an action similar to pg_logical_slot_get_changes()
> > implicitly from pg_sync_replication_slots()? Would there be any
> > implications of doing so?
> >
>
> Yes, there would be implications if we did it that way. It would mean
> that the consumer of the slot may not process those changes (for which
> sync_slot API has done the get_changes) and send it to the client.
> Consider a publisher-subscriber and physical standby setup. In this
> setup, the subscriber creates a logical slot corresponding to the
> subscription on the publisher. Now, the publisher process changes and
> sends it to the subscriber; then the slot is advanced (both its xmin
> and WAL locations) once the corresponding changes are sent to the
> client.
>
> If we allow pg_sync_replication_slots() to do
> pg_logical_slot_get_changes or equivalent in some way, then we may end
> up advancing the slot without sending the changes to the subscriber,
> which would be considered a data loss for the subscriber.
>
> I have explained in terms of built-in logical replication, but the
> external plugins using these APIs (pg_logical_*) should be doing
> something similar to process the changes and advance the slot.
>
> Does this answer your question and make sense to you?
>

Yes, understood. Thank you!

Regards,
Amul

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhou, Zhiguo 2025-05-30 11:30:39 Optimize shared LWLock acquisition for high-core-count systems
Previous Message Ajin Cherian 2025-05-30 11:11:28 Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding