Re: Logical Replication of sequences

From: vignesh C <vignesh21(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Euler Taveira <euler(at)eulerto(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>
Subject: Re: Logical Replication of sequences
Date: 2025-09-04 16:50:43
Message-ID: CALDaNm0ktmqgYoTa5PCMu1ErcOdrai_VDeE18bOZjL4r8YbkNw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 3 Sept 2025 at 13:04, Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Dear Vignesh,
>
> Thanks for updating the patch. Few comments:
> 01.
> ```
> /* Find the leader apply worker and signal it. */
> logicalrep_worker_wakeup(MyLogicalRepWorker->subid, InvalidOid);
> ```
>
> Sequencesync worker does not need to send a signal to the apply worker.
> Should we skip in the case?
> Per my understanding, the signal is being used to set the status to STATE_READY.

Modified

> 02.
> ```
> if (worker)
> worker->last_seqsync_start_time = 0;
>
> LWLockRelease(LogicalRepWorkerLock);
> ```
>
> I feel we can release LWLock first then update last_seqsync_start_time.

I felt it should be done within lock so that
ProcessSyncingSequencesForApply waits till the last_seqsync_start_time
is also set.

> 03.
> Sequencesync worker cannot update its GUC parameters because ProcessConfigFile()
> is not called. How about checking the signal at the end of batch loop?

Modified

> 04.
> ```
> while (search_pos < total_seqs)
> {
> LogicalRepSequenceInfo *candidate_seq = lfirst(list_nth_cell(sequences_to_copy, search_pos));
>
> if (!strcmp(candidate_seq->nspname, nspname) &&
> !strcmp(candidate_seq->seqname, seqname))
> {
> seqinfo = candidate_seq;
> search_pos++;
> break;
> }
>
> search_pos++;
> }
> ```
>
> It looks like that if the entry in sequences_to_copy is skipped, it won't be
> referred anymore. I feel this is method is bit dangerous, because ordering of
> the list may be different with the returned tuples from the publisher. Nodes may
> use the different collations.

Modified

The attached patch has the changes for the same.

Regards,
Vignesh

Attachment Content-Type Size
v20250904-0001-Enhance-pg_get_sequence_data-function.patch text/x-patch 7.4 KB
v20250904-0002-Introduce-ALL-SEQUENCES-support-for-Postgr.patch text/x-patch 110.7 KB
v20250904-0005-Introduce-REFRESH-PUBLICATION-SEQUENCES-fo.patch text/x-patch 40.0 KB
v20250904-0003-Reorganize-tablesync-Code-and-Introduce-sy.patch text/x-patch 24.6 KB
v20250904-0004-Update-ALTER-SUBSCRIPTION-REFRESH-to-ALTER.patch text/x-patch 8.9 KB
v20250904-0006-New-worker-for-sequence-synchronization-du.patch text/x-patch 91.9 KB
v20250904-0007-Documentation-for-sequence-synchronization.patch text/x-patch 35.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-09-04 16:59:08 Re: [PATCH] Let's get rid of the freelist and the buffer_strategy_lock
Previous Message Sami Imseih 2025-09-04 16:50:15 Re: PgStat_HashKey padding issue when passed by reference