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, 19 Jan 2016 03:29:02 +0000 (08:59 +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 b20f9d7e75b053a242a64a7df33f5821d9dd3bd7..bfa2433dd05511a467b01a7a604e998133cc8792 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;
 }