Fix: might recycle wrong gang size.
In buildGangDefinition, newGangDefinition->db_descriptors are
initialized one by one, but newGangDefinition->size was already
set to its final value. If an error was caught, its size should
be reset to the right number.
@@ -230,7 +230,7 @@ buildGangDefinition(List *segments, SegmentType segmentType)
{
Gang *newGangDefinition = NULL;
ListCell *lc;
- int i = 0;
+ volatile int i = 0;
int size;
int contentId;
@@ -260,6 +260,7 @@ buildGangDefinition(List *segments, SegmentType segmentType)
}
PG_CATCH();
{
+ newGangDefinition->size = i;
RecycleGang(newGangDefinition, true /* destroy */);
PG_RE_THROW();
}
