Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2krh-0002GI-I6 for pgsql-jdbc@arkaria.postgresql.org; Wed, 07 Dec 2022 03:12:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2krg-0001qP-43 for pgsql-jdbc@arkaria.postgresql.org; Wed, 07 Dec 2022 03:12:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2krf-0001lt-Qw for pgsql-jdbc@lists.postgresql.org; Wed, 07 Dec 2022 03:12:55 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2krd-0004kz-Hn for pgsql-jdbc@lists.postgresql.org; Wed, 07 Dec 2022 03:12:54 +0000 Received: by mail-wm1-x329.google.com with SMTP id v7so12648856wmn.0 for ; Tue, 06 Dec 2022 19:12:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ugne9PQssIIxdhPQog8eAWN66XMx+5fGX5z5YSxUvZQ=; b=URL/efN5RLBw6lCoRSGeZU2QkneSxzh620/NJj/m7Y7Lhh74+4o4T1YboTW/NQlZZ8 rHbP24UlYr/5Yar4fFKttMduBcQcvwIAF4Oii3+4c5/krC87hZfQQj18JiP5eqhSPmHq hThqzFHAkpGTN3z79m5l6y5s4vx8Qe1N9DYb9OpFIW07xylm0i0eHm/Ei6gmU9uEfKb+ q0rHZqaAuGi+HiioTMnTh81vqKj32R/C7slSW+wHDXLgBqxeVlSIMLRxqyhiZWus+juH 4XKR309IX/lc5HG2NZwaASDKQOfzgDQhWE+8gY8IPLjTMxUDN0Cf5/mJ31yNUncW/w3Y MCvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ugne9PQssIIxdhPQog8eAWN66XMx+5fGX5z5YSxUvZQ=; b=UecJfDiQalDIsxlfjxHEn1yeuOSiMSiG5EVpM8Wk267hKAu3bJmh2H80YrXD/qSPpV dYybYayYRW57uzDjn0a/5zrVNc++rIVooypQai8P9N7F7Zq6RtPKSAAN3sR6JLVteG+8 mlNRRX+Ox+rtQorhfclYttUAhlFBGaT0lx2aCRq2O8mtLLNJ2Xz+yaznF9OAny64haB5 bg27+J5Zli406/dGpWjRHBkyTMAlVBCANYTBZpz/BLLLNUH3hky0BN+7C+v1pD6xqasE 3GXIIZNhIf6AJtefXvD2Kv/m1vqUv9guRb5+9xbYrLzEwhVlp3Zg1fe9d/+txu9KRT3o mIlg== X-Gm-Message-State: ANoB5pn1yPXDw8rEuGtnqlzJvI66gHF3kz/hDnboF9O8UCalq/iglueK y/6Fkgn/jcIrJbemOw/xoK06YGHaYzQUSbbOwV8= X-Google-Smtp-Source: AA0mqf77wBFEYuFo4rQxTJDs21DsaPLk8OO+zdZC0oz+GeZMus9ZQMbJrHHI/r6BJCoqnPLjTRHehXQJ8UaDBbRQyOM= X-Received: by 2002:a05:600c:4e50:b0:3d0:bda:f2c with SMTP id e16-20020a05600c4e5000b003d00bda0f2cmr52381826wmq.117.1670382771701; Tue, 06 Dec 2022 19:12:51 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andy Fan Date: Wed, 7 Dec 2022 11:12:40 +0800 Message-ID: Subject: Re: Would preparing internally during XAResource.end(xid, TMSUCCESS) works? To: Dave Cramer Cc: pgsql-jdbc@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000bf0e6905ef344b6f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000bf0e6905ef344b6f Content-Type: text/plain; charset="UTF-8" Hi Dave: Thanks for your feedback and sorry for the late reply. Hi Andy, > > Sorry I'm not much help here. > > Were you able to figure this out? > > I've been working on this for a while. It would not work per current PG server code. The biggest issue is when user calls 'xa_end', he/she isn't intent to persist the 2pc transaction, but the PG code would do that during the 'prepare transaction' statement. In this case WE SHOULD NOT recover it again during crash recovery. I'm hacking the pg server code not do it until a user called 'xa_prepare'. The internal way to do this is: during xa_end, I run the 'prepare transaction xxx' statement and record a new xlog to rollback it 2pc, this is done at the end of the crash recovery stage. and If the user runs the 'xa_prepare', I would add another xlog to let the above thing not happen at the end of the crash recovery stage. (I hacked both JDBC driver and server code for the above stuff) Besides this, I also find another issue that connection 1: xa_start('foo', ..); insert into t select 1; xa_end('foo', ..); connection 2: xa_start('foo', ..); select * from t; ==> The above insert from connection 1 is visible for current connection, but in our JDBC it doesn't. I am also hacking this case as well, just record the transaction xid which the 'foo' belongs to and add a new rule to the MVCC to let the tuple be visible as well. still tuned and testing now. -- Best Regards Andy Fan --000000000000bf0e6905ef344b6f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi=C2=A0Dave:

Thanks for you= r feedback and sorry for the late reply.

Hi=C2=A0Andy,

Sorry I'm not mu= ch help here.

Were you able to figure this out?


I've been working on this for a while.=C2=A0 It w= ould not work per
current=C2=A0 PG server code.=C2=A0 The biggest= issue is when user=C2=A0
calls 'xa_end',=C2=A0 =C2=A0he/= she isn't intent to persist the 2pc
transaction, but the PG c= ode would do that during the 'prepare
transaction' statem= ent.=C2=A0 In this case WE SHOULD NOT recover
it again during cra= sh recovery.=C2=A0 =C2=A0I'm hacking the pg server code=C2=A0
not do it until a user called 'xa_prepare'.

The internal way to do this is: during xa_end,=C2=A0 I run the 'prep= are
transaction xxx' statement and record a new xlog to rollb= ack it
2pc, this is done at the end of the crash recovery stage.= =C2=A0 =C2=A0and=C2=A0
If the user runs the 'xa_prepare',= =C2=A0 I would add another xlog to=C2=A0
let the above thing not = happen at the end of the crash recovery
stage.=C2=A0
(I hacked both JDBC driver and server code for the above stuff= )

Besides this, I also find another issue that

connection 1:
xa_start('foo', ..);<= /div>
insert into t select 1;
xa_end('foo', ..);

connection 2:
xa_start('foo', ..);
select * from t;=C2=A0 =3D=3D>=C2=A0 The above insert from conn= ection 1 is visible for
current connection, but in our JDBC it do= esn't.=C2=A0

I am also hacking this case as we= ll, just record the transaction xid=C2=A0
which the 'foo'= belongs to and add a new rule to the MVCC to let
the tuple be vi= sible as well.=C2=A0

still tuned and testing now.<= /div>

--
Best Regards
Andy Fan
--000000000000bf0e6905ef344b6f--