RE: Slow catchup of 2PC (twophase) transactions on replica in LR

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Amit Kapila' <amit(dot)kapila16(at)gmail(dot)com>
Cc: Ajin Cherian <itsajin(at)gmail(dot)com>, Давыдов Виталий <v(dot)davydov(at)postgrespro(dot)ru>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: Slow catchup of 2PC (twophase) transactions on replica in LR
Date: 2024-07-05 05:39:05
Message-ID: OSBPR01MB25527C8A6257443FAE7391C3F5DF2@OSBPR01MB2552.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Amit,

Thanks for giving comments. I hope all comments have been addressed.
PSA new version.

> > Actually, earlier version (-v3) did not have a mechanism but they sometimes got
> > assertion failures in maybe_reread_subscription(). This was because the
> survived
> > workers read pg_subscription catalog and failed below assertion:
> >
> > ```
> > /* two-phase cannot be altered while the worker exists */
> > Assert(newsub->twophasestate ==
> MySubscription->twophasestate);
> > ```
> >
>
> But that is not a good reason for this operation to stop workers
> first. Instead, we should prohibit this operation if any worker is
> present. The reason is that there is always a chance that if any
> worker is alive, it can prepare a new transaction after we have
> checked for the presence of any prepared transactions.

I used the function because it internally waits until all workers are exited.
But OK, I modified like you suggested (logicalrep_workers_find() is used).

Best Regards,
Hayato Kuroda
FUJITSU LIMITED
https://www.fujitsu.com/

Attachment Content-Type Size
v15-0001-Allow-altering-of-two_phase-option-of-a-SUBSCRIP.patch application/octet-stream 27.6 KB
v15-0002-Alter-slot-option-two_phase-only-when-altering-t.patch application/octet-stream 11.3 KB
v15-0003-Abort-prepared-transactions-while-altering-two_p.patch application/octet-stream 11.3 KB
v15-0004-Add-force_alter-option-for-ALTER-SUBSCRIPTION-.-.patch application/octet-stream 56.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2024-07-05 05:40:00 Re: walsender.c comment with no context is hard to understand
Previous Message Michael Paquier 2024-07-05 05:29:26 Re: Test to dump and restore objects left behind by regression