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
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;
}