mirror of https://github.com/citusdata/citus.git
Dynamically allocate connection metadata in WaitForAllConnections
parent
e6ebfc1f53
commit
15511f6ba1
|
@ -744,16 +744,12 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
|||
int connectionIndex = 0;
|
||||
ListCell *connectionCell = NULL;
|
||||
|
||||
MultiConnection *allConnections[REMOTE_MAX_CONNECTIONS];
|
||||
WaitEvent events[REMOTE_MAX_CONNECTIONS];
|
||||
bool connectionReady[REMOTE_MAX_CONNECTIONS];
|
||||
MultiConnection **allConnections =
|
||||
palloc(totalConnectionCount * sizeof(MultiConnection *));
|
||||
WaitEvent *events = palloc(totalConnectionCount * sizeof(WaitEvent));
|
||||
bool *connectionReady = palloc(totalConnectionCount * sizeof(bool));
|
||||
WaitEventSet *waitEventSet = NULL;
|
||||
|
||||
if (totalConnectionCount > REMOTE_MAX_CONNECTIONS)
|
||||
{
|
||||
ereport(ERROR, (errmsg("too many connections")));
|
||||
}
|
||||
|
||||
/* convert connection list to an array such that we can move items around */
|
||||
foreach(connectionCell, connectionList)
|
||||
{
|
||||
|
@ -765,8 +761,7 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
|||
}
|
||||
|
||||
/* make an initial pass to check for failed and idle connections */
|
||||
for (connectionIndex = pendingConnectionsStartIndex;
|
||||
connectionIndex < totalConnectionCount; connectionIndex++)
|
||||
for (connectionIndex = 0; connectionIndex < totalConnectionCount; connectionIndex++)
|
||||
{
|
||||
MultiConnection *connection = allConnections[connectionIndex];
|
||||
|
||||
|
@ -953,6 +948,10 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
|||
FreeWaitEventSet(waitEventSet);
|
||||
waitEventSet = NULL;
|
||||
}
|
||||
|
||||
pfree(allConnections);
|
||||
pfree(events);
|
||||
pfree(connectionReady);
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
|
@ -963,6 +962,10 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
|||
waitEventSet = NULL;
|
||||
}
|
||||
|
||||
pfree(allConnections);
|
||||
pfree(events);
|
||||
pfree(connectionReady);
|
||||
|
||||
PG_RE_THROW();
|
||||
}
|
||||
PG_END_TRY();
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#define QUERY_SEND_FAILED 1
|
||||
#define RESPONSE_NOT_OKAY 2
|
||||
|
||||
#define REMOTE_MAX_CONNECTIONS 1024
|
||||
|
||||
struct pg_result; /* target of the PGresult typedef */
|
||||
|
||||
/* GUC, determining whether statements sent to remote nodes are logged */
|
||||
|
|
Loading…
Reference in New Issue