mirror of https://github.com/citusdata/citus.git
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
parent
484cb12cd0
commit
2489c59c15
|
@ -837,7 +837,18 @@ CheckShardPlacements(ConnectionShardHashEntry *shardEntry,
|
||||||
|
|
||||||
if (placementEntry->failed)
|
if (placementEntry->failed)
|
||||||
{
|
{
|
||||||
UpdateShardPlacementState(placementEntry->key.placementId, FILE_INACTIVE);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue