Allow COMMIT/ROLLBACK PREPARED xact to succeed on the local coordinator even if
authorPavan Deolasee <[email protected]>
Fri, 30 Sep 2016 10:17:36 +0000 (15:47 +0530)
committerPavan Deolasee <[email protected]>
Tue, 18 Oct 2016 10:07:48 +0000 (15:37 +0530)
the GTM no longer has state information for the transaction when
xc_maintenance_mode is active.

Information on the GTM is important for explicit prepared transactions because
GTM tracks the participants nodes in that case and the COMMIT/ROLLBACK PREPARED
commands can then to forwarded to those participants. So when
xc_maintenance_mode is active, we only cleanup prepared transaction on the
local node (or remote when used with EXECUTE DIRECT). So it seems ok not to
guarantee the GTM to have the state information.

src/backend/pgxc/pool/execRemote.c

index bce09736ebe5b1f005fed1a28d8872b7d37d8743..31568660f0b2f3e7e73d9b0f0d34fb8f43eb3ce8 100644 (file)
@@ -4242,8 +4242,16 @@ FinishRemotePreparedTransaction(char *prepareGID, bool commit)
         * single call, it doesn't look nicer and create confusion. We should
         * probably split them into two parts. This is used only for explicit 2PC
         * which should not be very common in XC
+        *
+        * In xc_maintenance_mode mode, we don't fail if the GTM does not have
+        * knowledge about the prepared transaction. That may happen for various
+        * reasons such that an earlier attempt cleaned up it from GTM or GTM was
+        * restarted in between. The xc_maintenance_mode is a kludge to come out of
+        * such situations. So it seems alright to not be too strict about the
+        * state
         */
-       if (GetGIDDataGTM(prepareGID, &gxid, &prepare_gxid, &nodestring) < 0)
+       if ((GetGIDDataGTM(prepareGID, &gxid, &prepare_gxid, &nodestring) < 0) &&
+               !xc_maintenance_mode)
                ereport(ERROR,
                                (errcode(ERRCODE_INTERNAL_ERROR),
                                 errmsg("prepared transaction with identifier \"%s\" does not exist",