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]>
Fri, 30 Sep 2016 10:17:36 +0000 (15:47 +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 7aa2ba96c3377b73d21e862af3ba8ed55757b40a..105b4ebf05a659f3b3a1dfaa34e98bb99a298c55 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",