| From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | shveta malik <shveta(dot)malik(at)gmail(dot)com>, shihao zhong <zhong950419(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, saurabh singh <saurabh(dot)singh214(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, shveta malik <shvetamalik(at)gmail(dot)com> |
| Subject: | Re: Proposal: Conflict log history table for Logical Replication |
| Date: | 2026-11-09 05:30:13 |
| Message-ID: | CAA4eK1J6m=VukMa5DjRb0rarCiLR+ZP_9z7NHH4OUW0O27K_LQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Nov 9, 2026 at 10:17 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Tue, Nov 3, 2026 at 2:31 AM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> >
> > Yes, I also thought about it previously and felt the same. To achieve
> > this we need to scan the lock table for holders on the relation and
> > match them to the subscription's prepared transactions (their dummy
> > PGPROCs). See attached top-up atop v88 generated by AI. I can
> > review/test it more if we decide to go with this strategy. I still
> > feel we shouldn't add this because such scenarios will be rare in
> > practice. It won't be difficult to address this if we really see such
> > field reports, so I would like to leave this code as is but if you
> > still think otherwise then we can take care with finding whether
> > prepared xact has locked CLT.
>
> I'm not sure it's that rare. Tuples copied by the initial table sync
> always cause a conflict (update_origin_differs or
> delete_origin_differs) when the apply worker modifies them for the
> first time, if track_commit_timestamp is enabled. Also, in systems
> using two-phase commit, it's common that the subscription has prepared
> transactions. But I might be worrying too much.
>
> TBH I'm still not sure why we really need the special behavior of
> erroring out only for the CLT. I agree that it's an internal behavior
> and users might not be aware of it, but I think users who don't know
> it would be equally confused when the apply worker errors out because
> of it.
>
I see your point. So, what should we do instead? We can remove this
extra handling for prepared xact from apply_worker and document it.
Prepare Transaction already notes as follows: "PREPARE TRANSACTION is
not intended for use in applications or interactive sessions. Its
purpose is to allow an external transaction manager to perform atomic
global transactions across multiple databases or other transactional
resources. Unless you're writing a transaction manager, you probably
shouldn't be using PREPARE TRANSACTION.". Then there is a long Caution
Note [1], shall we document the additional hazards with respect to
apply worker both for normal and CLT tables?
[1]: https://www.postgresql.org/docs/devel/sql-prepare-transaction.html
--
With Regards,
Amit Kapila.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-11-09 05:37:42 | Re: Draft back-branch release notes are up |
| Previous Message | David Rowley | 2026-11-09 05:11:37 | Re: Wrong results with initplans moved by setrefs.c |