Use XID passed down by the remote datanode, if its available, when
authorPavan Deolasee <[email protected]>
Tue, 19 Jan 2016 03:29:02 +0000 (08:59 +0530)
committerPavan Deolasee <[email protected]>
Tue, 18 Oct 2016 09:42:41 +0000 (15:12 +0530)
GetCurrentTransactionIdIfAny() is called.

The regular GetCurrentTransactionId() does the same, without actually storing
the XID in the transaction state. We don't store the XID when the connection is
from a datanode, to ensure that a duplicate XID is not stored. There are other
technique employed to ensure multiple backends can participate in the same
global transaction.

This bug was causing wrong results when a query needs datanode-datanode
connections and updates are made previously in the same transaction, via a
different connection

Per report by Arun Shaji

src/backend/access/transam/xact.c

index 6f84a48f0327de6f0e55ae8c6c6976062c43b1f9..a32ac5f8f1729f76a6a7beb5cacd8b4d5d85ee1f 100644 (file)
@@ -548,6 +548,14 @@ GetCurrentTransactionId(void)
 TransactionId
 GetCurrentTransactionIdIfAny(void)
 {
+#ifdef XCP
+       /*
+        * Return XID if its available from the remote node, without assigning to
+        * the transaction state
+        */
+       if (IsConnFromDatanode())
+               return GetNextTransactionId();
+#endif
        return CurrentTransactionState->transactionId;
 }