In case of failed transactions update shard state only if it is FILE_FINALIZED

Before this change, when a transaction failed, we update related placements shard states
to FILE_INACTIVE during XACT_EVENT_PRE_COMMIT. However that means if another code block
changed shard state to something else (e.g. FILE_TO_DELETE) before XACT_EVENT_PRE_COMMIT
we overwrite that. To prevent that problem, in case of failure we started to change
shard state, only if its current shard state is FILE_FINALIZED.
pull/1136/head
Burak Yucesoy 2017-01-18 12:01:28 +02:00
parent 484cb12cd0
commit 2489c59c15
1 changed files with 12 additions and 1 deletions

View File

@ -836,10 +836,21 @@ CheckShardPlacements(ConnectionShardHashEntry *shardEntry,
dlist_container(ConnectionPlacementHashEntry, shardNode, placementIter.cur);
if (placementEntry->failed)
{
uint64 shardId = shardEntry->key.shardId;
uint64 placementId = placementEntry->key.placementId;
ShardPlacement *shardPlacement = LoadShardPlacement(shardId, placementId);
/*
* We only set shard state if its current state is FILE_FINALIZED, which
* prevents overwriting shard state if it is already set at somewhere else.
*/
if (shardPlacement->shardState == FILE_FINALIZED)
{
UpdateShardPlacementState(placementEntry->key.placementId, FILE_INACTIVE);
}
}
}
return true;
}