mirror of https://github.com/citusdata/citus.git
Make outside tx more explicit
parent
766f340ce0
commit
747b8fc5a5
|
@ -437,7 +437,8 @@ FindAvailableConnection(dlist_head *connections, uint32 flags)
|
|||
MultiConnection *connection =
|
||||
dlist_container(MultiConnection, connectionNode, iter.cur);
|
||||
|
||||
if (flags & OUTSIDE_TRANSACTION)
|
||||
bool outsideCoordinatedTx = (flags & OUTSIDE_TRANSACTION);
|
||||
if (outsideCoordinatedTx)
|
||||
{
|
||||
/* don't return connections that are used in transactions */
|
||||
if (connection->remoteTransaction.transactionState !=
|
||||
|
@ -492,6 +493,12 @@ FindAvailableConnection(dlist_head *connections, uint32 flags)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (outsideCoordinatedTx)
|
||||
{
|
||||
connection->remoteTransaction.transactionState =
|
||||
REMOTE_TRANS_OUTSIDE_COORDINATED_TX;
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,14 @@ StartRemoteTransactionBegin(struct MultiConnection *connection)
|
|||
{
|
||||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
||||
|
||||
Assert(transaction->transactionState == REMOTE_TRANS_NOT_STARTED);
|
||||
Assert(transaction->transactionState == REMOTE_TRANS_NOT_STARTED ||
|
||||
transaction->transactionState == REMOTE_TRANS_OUTSIDE_COORDINATED_TX);
|
||||
|
||||
/* remember transaction as being in-progress */
|
||||
dlist_push_tail(&InProgressTransactions, &connection->transactionNode);
|
||||
if (transaction->transactionState != REMOTE_TRANS_OUTSIDE_COORDINATED_TX)
|
||||
{
|
||||
dlist_push_tail(&InProgressTransactions, &connection->transactionNode);
|
||||
}
|
||||
|
||||
transaction->transactionState = REMOTE_TRANS_STARTING;
|
||||
|
||||
|
@ -761,10 +765,9 @@ CloseRemoteTransaction(struct MultiConnection *connection)
|
|||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
||||
|
||||
/* unlink from list of open transactions, if necessary */
|
||||
if (transaction->transactionState != REMOTE_TRANS_NOT_STARTED)
|
||||
if (transaction->transactionState != REMOTE_TRANS_NOT_STARTED &&
|
||||
transaction->transactionState != REMOTE_TRANS_OUTSIDE_COORDINATED_TX)
|
||||
{
|
||||
/* XXX: Should we error out for a critical transaction? */
|
||||
|
||||
dlist_delete(&connection->transactionNode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,9 @@ typedef enum
|
|||
/* transaction commit */
|
||||
REMOTE_TRANS_1PC_COMMITTING,
|
||||
REMOTE_TRANS_2PC_COMMITTING,
|
||||
REMOTE_TRANS_COMMITTED
|
||||
REMOTE_TRANS_COMMITTED,
|
||||
|
||||
REMOTE_TRANS_OUTSIDE_COORDINATED_TX,
|
||||
} RemoteTransactionState;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue