Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rwOJO-001KWu-5d for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Apr 2024 15:32:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rwOJM-00DqRl-6Z for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Apr 2024 15:32:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rwOJL-00DqRd-S5 for pgsql-hackers@lists.postgresql.org; Mon, 15 Apr 2024 15:31:59 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rwOJI-0016Fq-Vq for pgsql-hackers@lists.postgresql.org; Mon, 15 Apr 2024 15:31:58 +0000 Received: from sogo.postgrespro.ru (unknown [192.168.2.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix/587) with ESMTPS id 36447E20E94; Mon, 15 Apr 2024 18:31:55 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1713195115; bh=pjGwsesEWMwz1MWXKCkVz3S5Iw19kfIArq0/uf+33Kc=; h=From:In-Reply-To:References:Date:Cc:To:Message-ID:Subject: User-Agent:From; b=KzHjK2NQ1LY70ZnVhwtgb0bJAHj1Lp3UQDOAjEsdqu+our3S1PoWTLIdKWNhaOtdx 7AITOF9gu7yWOz+HJo3brlzj1I/6s0qV2XAXx1QMdvdynzcP1RMl/LK27wu911A89V 7dc6ZQUV8w3nMqx9JVgsy2NmDM72TDRbJQm1s44Wxz1WYkzxDcS9nWBMIqSnJjZkvV Uq+dxmQyAvWtxtUZJi3INIl0BjFEC+lk2AXufidtpdLo5xBQJ8xt3Jxo1Q3/KR8Hro IxxMtZTJxsEEj1HHhePFhSn1xJUnvI4ZPtnxHzLTq6o4jJq4PFLvx7dbQstHu1jRqn 86BzFnCQ6zjpw== From: =?utf-8?q?=D0=94=D0=B0=D0=B2=D1=8B=D0=B4=D0=BE=D0=B2_=D0=92=D0=B8=D1=82=D0=B0=D0=BB=D0=B8=D0=B9?= In-Reply-To: <23d1ca-66169f80-1f-5a90aa00@207285398> Content-Type: multipart/alternative; boundary="----=_=-_OpenGroupware_org_NGMime-2536206-1713195115.092809-4------" X-Forward: 46.31.29.106 References: <8fab8-65d74c80-1-2f28e880@39088166> <99df2-65d8d200-1-63c26880@172687752> <23d1ca-66169f80-1f-5a90aa00@207285398> Date: Mon, 15 Apr 2024 18:31:55 +0300 Cc: "Amit Kapila" , "Ajin Cherian" , "Heikki Linnakangas" , pgsql-hackers@lists.postgresql.org To: =?utf-8?q?=D0=94=D0=B0=D0=B2=D1=8B=D0=B4=D0=BE=D0=B2_=D0=92=D0=B8=D1=82=D0=B0=D0=BB=D0=B8=D0=B9?= MIME-Version: 1.0 Message-ID: <26b30e-661d4880-9-62d2df00@231402233> Subject: =?utf-8?q?Re=3A?= Slow catchup of 2PC (twophase) transactions on replica in LR User-Agent: SOGoMail 5.10.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------=_=-_OpenGroupware_org_NGMime-2536206-1713195115.092809-4------ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Length: 3050 Dear All, On Wednesday, April 10, 2024 17:16 MSK, =D0=94=D0=B0=D0=B2=D1=8B=D0=B4=D0= =BE=D0=B2 =D0=92=D0=B8=D1=82=D0=B0=D0=BB=D0=B8=D0=B9 wrote: =C2=A0Hi Amit, Ajin, All Thank you for the patch and the responses. I apologize for my delayed a= nswer due to some=C2=A0curcumstances. On Wednesday, April 10, 2024 14:18 MSK, Amit Kapila wrote: Vitaly, does the minimal solution provided by the proposed patch (Allow= to alter two=5Fphase option of a subscriber provided no uncommitted pr= epared transactions are pending on that subscription.) address your use= case?In general, the idea behind the patch seems to be suitable for my= case. Furthermore, the case of two=5Fphase switch from false to true w= ith uncommitted pending prepared transactions probably never happens in= my case. The switch from false to true means that the replica complete= s the catchup from the master and switches to the normal mode when it p= articipates in the multi-node configuration. There should be no uncommi= tted pending prepared transactions at the moment of the switch to the n= ormal mode. I'm going to try this patch. Give me please some time to investigate th= e patch. I will come with some feedback a little bit later. I looked at the patch and realized that I can't try it easily in the ne= ar future because the solution I'm working on is based on PG16 or earli= er. This patch is not easily applicable to the older releases. I have t= o port my solution to the master, which is not done yet. I apologize fo= r that - so much work should be done before applying the patch. BTW, I = tested the idea with async 2PC commit on my side and it seems to work f= ine in my case. Anyway, I agree, the idea with altering of subscription= seems the best one but much harder to implement. To summarise my case of a synchronous multimaster where twophase is use= d to implement global transactions: * Replica may have prepared but not committed transactions when I togg= le subscription twophase from true to false. In this case, all prepared= transactions may be aborted on the replica before altering=C2=A0the su= bscription. * Replica will=C2=A0not have prepared transactions when sub= scription is toggled from false to true. In this scenario, the replica = completes the catchup (with twophase=3Doff) and=C2=A0becomes the part o= f the multi-nodal cluster and is ready to accept new 2PC transactions. = All the new pending transactions will wait until replica responds. But = it may work=C2=A0differently=C2=A0for some other solutions. In general,= it would be great to allow toggling for all scenarious.Just interested= , does anyone tried to reproduce the problem with slow catchup of twoph= ase transactions (pgbench should be used with big number of clients)? I= haven't seen any messages from anyone other that me that the problem t= akes place.=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B Thank you for your help! With best regards, Vitaly =C2=A0 ------=_=-_OpenGroupware_org_NGMime-2536206-1713195115.092809-4------ Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Length: 3378 Dear All,

On Wednesday, April 10, 2024 17:16 MSK, =D0=94= =D0=B0=D0=B2=D1=8B=D0=B4=D0=BE=D0=B2 =D0=92=D0=B8=D1=82=D0=B0=D0=BB=D0=B8= =D0=B9 <v.davydov@postgrespro.ru> wrote:
 
Hi Amit, Aj= in, All

Thank you for the patch and the responses. I apologi= ze for my delayed answer due to some curcumstances.

= On Wednesday, April 10, 2024 14:18 MSK, Amit Kapila <amit.kapila16@g= mail.com> wrote:

Vitaly, does the minimal solution provid= ed by the proposed patch (Allow to alter two=5Fphase option of a subscr= iber provided no uncommitted prepared transactions are pending on that = subscription.) address your use case?

In general, the i= dea behind the patch seems to be suitable for my case. Furthermore, the= case of two=5Fphase switch from false to true with uncommitted pending= prepared transactions probably never happens in my case. The switch fr= om false to true means that the replica completes the catchup from the = master and switches to the normal mode when it participates in the mult= i-node configuration. There should be no uncommitted pending prepared t= ransactions at the moment of the switch to the normal mode.

= I'm going to try this patch. Give me please some time to investigate th= e patch. I will come with some feedback a little bit later.
I looked at the patch and realized that I can't try it easily in= the near future because the solution I'm working on is based on PG16 o= r earlier. This patch is not easily applicable to the older releases. I= have to port my solution to the master, which is not done yet. I apolo= gize for that - so much work should be done before applying the patch. = BTW, I tested the idea with async 2PC commit on my side and it seems to= work fine in my case. Anyway, I agree, the idea with altering of subsc= ription seems the best one but much harder to implement.

To = summarise my case of a synchronous multimaster where twophase is used t= o implement global transactions:
  • Replica may have prepared but n= ot committed transactions when I toggle subscription twophase from true= to false. In this case, all prepared transactions may be aborted on th= e replica before altering the subscription.
  • Replica will&n= bsp;not have prepared transactions when subscription is toggled from fa= lse to true. In this scenario, the replica completes the catchup (with = twophase=3Doff) and becomes the part of the multi-nodal cluster an= d is ready to accept new 2PC transactions. All the new pending transact= ions will wait until replica responds. But it may work differently=  for some other solutions. In general, it would be great to allow = toggling for all scenarious.
Just interested, does anyone trie= d to reproduce the problem with slow catchup of twophase transactions (= pgbench should be used with big number of clients)? I haven't seen any = messages from anyone other that me that the problem takes place.=E2=80=8B= =E2=80=8B=E2=80=8B=E2=80=8B

Thank you for your help!
With best regards,
Vitaly





<= br />



  ------=_=-_OpenGroupware_org_NGMime-2536206-1713195115.092809-4--------