Don't override xact id assigned by coordinator on workers.

We might need to send commands from workers to other workers. In
these cases we shouldn't override the xact id assigned by coordinator,
or otherwise we won't read the consistent set of result files
accross the nodes.
pull/3363/head
Hadi Moshayedi 2020-01-09 11:09:11 -08:00
parent bb65669186
commit e1e383cb59
2 changed files with 24 additions and 2 deletions

View File

@ -117,7 +117,8 @@ static bool MaybeExecutingUDF(void);
void
UseCoordinatedTransaction(void)
{
if (CurrentCoordinatedTransactionState == COORD_TRANS_STARTED)
if (CurrentCoordinatedTransactionState == COORD_TRANS_STARTED ||
CurrentCoordinatedTransactionState == COORD_TRANS_STARTED_ON_WORKER)
{
return;
}
@ -130,7 +131,21 @@ UseCoordinatedTransaction(void)
CurrentCoordinatedTransactionState = COORD_TRANS_STARTED;
AssignDistributedTransactionId();
/*
* This might be part of bigger distributed transaction originating from
* another node, in which case transaction id has already been assigned
* by a assign_distributed_transaction_id() call.
*/
DistributedTransactionId *transactionId = GetCurrentDistributedTransactionId();
if (transactionId->transactionNumber == 0)
{
CurrentCoordinatedTransactionState = COORD_TRANS_STARTED_ON_WORKER;
AssignDistributedTransactionId();
}
else
{
CurrentCoordinatedTransactionState = COORD_TRANS_STARTED;
}
}

View File

@ -35,6 +35,13 @@ typedef enum CoordinatedTransactionState
/* no coordinated transaction in progress, but connections established */
COORD_TRANS_IDLE,
/*
* Coordinated transaction was initiated by coordinator, but the worker also
* needs to start a coordinated transaction to be able to send commands to
* other workers.
*/
COORD_TRANS_STARTED_ON_WORKER,
/* coordinated transaction in progress */
COORD_TRANS_STARTED,