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;
|
int connectionIndex = 0;
|
||||||
ListCell *connectionCell = NULL;
|
ListCell *connectionCell = NULL;
|
||||||
|
|
||||||
MultiConnection *allConnections[REMOTE_MAX_CONNECTIONS];
|
MultiConnection **allConnections =
|
||||||
WaitEvent events[REMOTE_MAX_CONNECTIONS];
|
palloc(totalConnectionCount * sizeof(MultiConnection *));
|
||||||
bool connectionReady[REMOTE_MAX_CONNECTIONS];
|
WaitEvent *events = palloc(totalConnectionCount * sizeof(WaitEvent));
|
||||||
|
bool *connectionReady = palloc(totalConnectionCount * sizeof(bool));
|
||||||
WaitEventSet *waitEventSet = NULL;
|
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 */
|
/* convert connection list to an array such that we can move items around */
|
||||||
foreach(connectionCell, connectionList)
|
foreach(connectionCell, connectionList)
|
||||||
{
|
{
|
||||||
|
@ -765,8 +761,7 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make an initial pass to check for failed and idle connections */
|
/* make an initial pass to check for failed and idle connections */
|
||||||
for (connectionIndex = pendingConnectionsStartIndex;
|
for (connectionIndex = 0; connectionIndex < totalConnectionCount; connectionIndex++)
|
||||||
connectionIndex < totalConnectionCount; connectionIndex++)
|
|
||||||
{
|
{
|
||||||
MultiConnection *connection = allConnections[connectionIndex];
|
MultiConnection *connection = allConnections[connectionIndex];
|
||||||
|
|
||||||
|
@ -953,6 +948,10 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
||||||
FreeWaitEventSet(waitEventSet);
|
FreeWaitEventSet(waitEventSet);
|
||||||
waitEventSet = NULL;
|
waitEventSet = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pfree(allConnections);
|
||||||
|
pfree(events);
|
||||||
|
pfree(connectionReady);
|
||||||
}
|
}
|
||||||
PG_CATCH();
|
PG_CATCH();
|
||||||
{
|
{
|
||||||
|
@ -963,6 +962,10 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
||||||
waitEventSet = NULL;
|
waitEventSet = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pfree(allConnections);
|
||||||
|
pfree(events);
|
||||||
|
pfree(connectionReady);
|
||||||
|
|
||||||
PG_RE_THROW();
|
PG_RE_THROW();
|
||||||
}
|
}
|
||||||
PG_END_TRY();
|
PG_END_TRY();
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#define QUERY_SEND_FAILED 1
|
#define QUERY_SEND_FAILED 1
|
||||||
#define RESPONSE_NOT_OKAY 2
|
#define RESPONSE_NOT_OKAY 2
|
||||||
|
|
||||||
#define REMOTE_MAX_CONNECTIONS 1024
|
|
||||||
|
|
||||||
struct pg_result; /* target of the PGresult typedef */
|
struct pg_result; /* target of the PGresult typedef */
|
||||||
|
|
||||||
/* GUC, determining whether statements sent to remote nodes are logged */
|
/* GUC, determining whether statements sent to remote nodes are logged */
|
||||||
|
|
Loading…
Reference in New Issue