mirror of https://github.com/citusdata/citus.git
Run make reindent
parent
115ed00c06
commit
61714862a6
|
@ -2212,7 +2212,8 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation,
|
||||||
*/
|
*/
|
||||||
if (ShardIntervalListHasLocalPlacements(shardIntervalList))
|
if (ShardIntervalListHasLocalPlacements(shardIntervalList))
|
||||||
{
|
{
|
||||||
bool reservedConnection = TryConnectionPossibilityForLocalPrimaryNode(connectionFlags);
|
bool reservedConnection = TryConnectionPossibilityForLocalPrimaryNode(
|
||||||
|
connectionFlags);
|
||||||
copyDest->shouldUseLocalCopy = !reservedConnection;
|
copyDest->shouldUseLocalCopy = !reservedConnection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,7 +362,7 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
|
||||||
{
|
{
|
||||||
if (flags & REQUIRE_MAINTENANCE_CONNECTION)
|
if (flags & REQUIRE_MAINTENANCE_CONNECTION)
|
||||||
{
|
{
|
||||||
// Maintenance database may have changed, so cached connection should be closed
|
/* Maintenance database may have changed, so cached connection should be closed */
|
||||||
connection->forceCloseAtTransactionEnd = true;
|
connection->forceCloseAtTransactionEnd = true;
|
||||||
}
|
}
|
||||||
return connection;
|
return connection;
|
||||||
|
@ -1218,7 +1218,8 @@ CitusPQFinish(MultiConnection *connection)
|
||||||
int sharedCounterFlags = (connection->useForMaintenanceOperations)
|
int sharedCounterFlags = (connection->useForMaintenanceOperations)
|
||||||
? MAINTENANCE_CONNECTION
|
? MAINTENANCE_CONNECTION
|
||||||
: 0;
|
: 0;
|
||||||
DecrementSharedConnectionCounter(sharedCounterFlags, connection->hostname, connection->port);
|
DecrementSharedConnectionCounter(sharedCounterFlags, connection->hostname,
|
||||||
|
connection->port);
|
||||||
connection->initializationState = POOL_STATE_NOT_INITIALIZED;
|
connection->initializationState = POOL_STATE_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1524,7 +1525,8 @@ ShouldShutdownConnection(MultiConnection *connection, const int cachedConnection
|
||||||
connection->requiresReplication ||
|
connection->requiresReplication ||
|
||||||
connection->isReplicationOriginSessionSetup ||
|
connection->isReplicationOriginSessionSetup ||
|
||||||
(MaxCachedConnectionLifetime >= 0 &&
|
(MaxCachedConnectionLifetime >= 0 &&
|
||||||
MillisecondsToTimeout(connection->connectionEstablishmentStart, MaxCachedConnectionLifetime) <= 0);
|
MillisecondsToTimeout(connection->connectionEstablishmentStart,
|
||||||
|
MaxCachedConnectionLifetime) <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,8 @@ static ReservedConnectionHashEntry * AllocateOrGetReservedConnectionEntry(char *
|
||||||
userId, Oid
|
userId, Oid
|
||||||
databaseOid,
|
databaseOid,
|
||||||
bool *found);
|
bool *found);
|
||||||
static void EnsureConnectionPossibilityForNodeList(List *nodeList, uint32 connectionFlags);
|
static void EnsureConnectionPossibilityForNodeList(List *nodeList, uint32
|
||||||
|
connectionFlags);
|
||||||
static bool EnsureConnectionPossibilityForNode(WorkerNode *workerNode,
|
static bool EnsureConnectionPossibilityForNode(WorkerNode *workerNode,
|
||||||
bool waitForConnection,
|
bool waitForConnection,
|
||||||
uint32 connectionFlags);
|
uint32 connectionFlags);
|
||||||
|
@ -242,7 +243,8 @@ DeallocateReservedConnections(void)
|
||||||
* the shared memory as well.
|
* the shared memory as well.
|
||||||
*/
|
*/
|
||||||
int sharedCounterFlags = 0;
|
int sharedCounterFlags = 0;
|
||||||
DecrementSharedConnectionCounter(sharedCounterFlags, entry->key.hostname, entry->key.port);
|
DecrementSharedConnectionCounter(sharedCounterFlags, entry->key.hostname,
|
||||||
|
entry->key.port);
|
||||||
|
|
||||||
/* for completeness, set it to true */
|
/* for completeness, set it to true */
|
||||||
entry->usedReservation = true;
|
entry->usedReservation = true;
|
||||||
|
@ -332,7 +334,8 @@ TryConnectionPossibilityForLocalPrimaryNode(uint32 connectionFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool waitForConnection = false;
|
bool waitForConnection = false;
|
||||||
return EnsureConnectionPossibilityForNode(localNode, waitForConnection, connectionFlags);
|
return EnsureConnectionPossibilityForNode(localNode, waitForConnection,
|
||||||
|
connectionFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -365,7 +368,8 @@ EnsureConnectionPossibilityForNodeList(List *nodeList, uint32 connectionFlags)
|
||||||
foreach_ptr(workerNode, nodeList)
|
foreach_ptr(workerNode, nodeList)
|
||||||
{
|
{
|
||||||
bool waitForConnection = true;
|
bool waitForConnection = true;
|
||||||
EnsureConnectionPossibilityForNode(workerNode, waitForConnection, connectionFlags);
|
EnsureConnectionPossibilityForNode(workerNode, waitForConnection,
|
||||||
|
connectionFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +388,8 @@ EnsureConnectionPossibilityForNodeList(List *nodeList, uint32 connectionFlags)
|
||||||
* return false.
|
* return false.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
EnsureConnectionPossibilityForNode(WorkerNode *workerNode, bool waitForConnection, uint32 connectionFlags)
|
EnsureConnectionPossibilityForNode(WorkerNode *workerNode, bool waitForConnection, uint32
|
||||||
|
connectionFlags)
|
||||||
{
|
{
|
||||||
if (!IsReservationPossible(connectionFlags))
|
if (!IsReservationPossible(connectionFlags))
|
||||||
{
|
{
|
||||||
|
@ -442,7 +447,8 @@ EnsureConnectionPossibilityForNode(WorkerNode *workerNode, bool waitForConnectio
|
||||||
* no space left.
|
* no space left.
|
||||||
*/
|
*/
|
||||||
int sharedCounterFlags = 0;
|
int sharedCounterFlags = 0;
|
||||||
WaitLoopForSharedConnection(sharedCounterFlags, workerNode->workerName, workerNode->workerPort);
|
WaitLoopForSharedConnection(sharedCounterFlags, workerNode->workerName,
|
||||||
|
workerNode->workerPort);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,17 +141,24 @@ static bool ShouldWaitForConnection(int currentConnectionCount);
|
||||||
static uint32 SharedConnectionHashHash(const void *key, Size keysize);
|
static uint32 SharedConnectionHashHash(const void *key, Size keysize);
|
||||||
static int SharedConnectionHashCompare(const void *a, const void *b, Size keysize);
|
static int SharedConnectionHashCompare(const void *a, const void *b, Size keysize);
|
||||||
static uint32 SharedWorkerNodeDatabaseHashHash(const void *key, Size keysize);
|
static uint32 SharedWorkerNodeDatabaseHashHash(const void *key, Size keysize);
|
||||||
static int SharedWorkerNodeDatabaseHashCompare(const void *a, const void *b, Size keysize);
|
static int SharedWorkerNodeDatabaseHashCompare(const void *a, const void *b, Size
|
||||||
|
keysize);
|
||||||
static bool isConnectionThrottlingDisabled(uint32 externalFlags);
|
static bool isConnectionThrottlingDisabled(uint32 externalFlags);
|
||||||
static bool
|
static bool IncrementSharedConnectionCounterInternal(uint32 externalFlags, bool
|
||||||
IncrementSharedConnectionCounterInternal(uint32 externalFlags, bool checkLimits, const char *hostname, int port,
|
checkLimits, const char *hostname,
|
||||||
Oid database);
|
|
||||||
static SharedWorkerNodeConnStatsHashKey PrepareWorkerNodeHashKey(const char *hostname, int port);
|
|
||||||
static SharedWorkerNodeDatabaseConnStatsHashKey PrepareWorkerNodeDatabaseHashKey(const char *hostname,
|
|
||||||
int port,
|
int port,
|
||||||
Oid database);
|
Oid database);
|
||||||
static void
|
static SharedWorkerNodeConnStatsHashKey PrepareWorkerNodeHashKey(const char *hostname, int
|
||||||
DecrementSharedConnectionCounterInternal(uint32 externalFlags, const char *hostname, int port, Oid database);
|
port);
|
||||||
|
static SharedWorkerNodeDatabaseConnStatsHashKey PrepareWorkerNodeDatabaseHashKey(const
|
||||||
|
char *
|
||||||
|
hostname,
|
||||||
|
int port,
|
||||||
|
Oid
|
||||||
|
database);
|
||||||
|
static void DecrementSharedConnectionCounterInternal(uint32 externalFlags, const
|
||||||
|
char *hostname, int port, Oid
|
||||||
|
database);
|
||||||
|
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(citus_remote_connection_stats);
|
PG_FUNCTION_INFO_V1(citus_remote_connection_stats);
|
||||||
|
@ -195,7 +202,9 @@ StoreAllRemoteConnectionStats(Tuplestorestate *tupleStore, TupleDesc tupleDescri
|
||||||
SharedWorkerNodeDatabaseConnStatsHashEntry *connectionEntry = NULL;
|
SharedWorkerNodeDatabaseConnStatsHashEntry *connectionEntry = NULL;
|
||||||
|
|
||||||
hash_seq_init(&status, SharedWorkerNodeDatabaseConnStatsHash);
|
hash_seq_init(&status, SharedWorkerNodeDatabaseConnStatsHash);
|
||||||
while ((connectionEntry = (SharedWorkerNodeDatabaseConnStatsHashEntry *) hash_seq_search(&status)) != 0)
|
while ((connectionEntry =
|
||||||
|
(SharedWorkerNodeDatabaseConnStatsHashEntry *) hash_seq_search(
|
||||||
|
&status)) != 0)
|
||||||
{
|
{
|
||||||
/* get ready for the next tuple */
|
/* get ready for the next tuple */
|
||||||
memset(values, 0, sizeof(values));
|
memset(values, 0, sizeof(values));
|
||||||
|
@ -208,7 +217,8 @@ StoreAllRemoteConnectionStats(Tuplestorestate *tupleStore, TupleDesc tupleDescri
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
values[0] = PointerGetDatum(cstring_to_text(connectionEntry->key.workerNodeKey.hostname));
|
values[0] = PointerGetDatum(cstring_to_text(
|
||||||
|
connectionEntry->key.workerNodeKey.hostname));
|
||||||
values[1] = Int32GetDatum(connectionEntry->key.workerNodeKey.port);
|
values[1] = Int32GetDatum(connectionEntry->key.workerNodeKey.port);
|
||||||
values[2] = PointerGetDatum(cstring_to_text(databaseName));
|
values[2] = PointerGetDatum(cstring_to_text(databaseName));
|
||||||
values[3] = Int32GetDatum(connectionEntry->count);
|
values[3] = Int32GetDatum(connectionEntry->count);
|
||||||
|
@ -257,6 +267,7 @@ GetMaxSharedPoolSize(void)
|
||||||
return MaxSharedPoolSize;
|
return MaxSharedPoolSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
GetMaxMaintenanceSharedPoolSize(void)
|
GetMaxMaintenanceSharedPoolSize(void)
|
||||||
{
|
{
|
||||||
|
@ -303,6 +314,7 @@ WaitLoopForSharedConnection(uint32 flags, const char *hostname, int port)
|
||||||
ConditionVariableCancelSleep();
|
ConditionVariableCancelSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TryToIncrementSharedConnectionCounter tries to increment the shared
|
* TryToIncrementSharedConnectionCounter tries to increment the shared
|
||||||
* connection counter for the given nodeId and the current database in
|
* connection counter for the given nodeId and the current database in
|
||||||
|
@ -375,7 +387,8 @@ IncrementSharedConnectionCounterInternal(uint32 externalFlags,
|
||||||
* space in the shared memory. That's why we prefer continuing the execution
|
* space in the shared memory. That's why we prefer continuing the execution
|
||||||
* instead of throwing an error.
|
* instead of throwing an error.
|
||||||
*/
|
*/
|
||||||
SharedWorkerNodeConnStatsHashKey workerNodeKey = PrepareWorkerNodeHashKey(hostname, port);
|
SharedWorkerNodeConnStatsHashKey workerNodeKey = PrepareWorkerNodeHashKey(hostname,
|
||||||
|
port);
|
||||||
bool workerNodeEntryFound = false;
|
bool workerNodeEntryFound = false;
|
||||||
SharedWorkerNodeConnStatsHashEntry *workerNodeConnectionEntry =
|
SharedWorkerNodeConnStatsHashEntry *workerNodeConnectionEntry =
|
||||||
hash_search(SharedWorkerNodeConnStatsHash,
|
hash_search(SharedWorkerNodeConnStatsHash,
|
||||||
|
@ -429,14 +442,16 @@ IncrementSharedConnectionCounterInternal(uint32 externalFlags,
|
||||||
if (checkLimits)
|
if (checkLimits)
|
||||||
{
|
{
|
||||||
WorkerNode *workerNode = FindWorkerNode(hostname, port);
|
WorkerNode *workerNode = FindWorkerNode(hostname, port);
|
||||||
bool connectionToLocalNode = workerNode && (workerNode->groupId == GetLocalGroupId());
|
bool connectionToLocalNode = workerNode && (workerNode->groupId ==
|
||||||
|
GetLocalGroupId());
|
||||||
|
|
||||||
int currentConnectionsLimit;
|
int currentConnectionsLimit;
|
||||||
int currentConnectionsCount;
|
int currentConnectionsCount;
|
||||||
if (maintenanceConnection)
|
if (maintenanceConnection)
|
||||||
{
|
{
|
||||||
currentConnectionsLimit = GetMaxMaintenanceSharedPoolSize();
|
currentConnectionsLimit = GetMaxMaintenanceSharedPoolSize();
|
||||||
currentConnectionsCount = workerNodeConnectionEntry->maintenanceConnectionsCount;
|
currentConnectionsCount =
|
||||||
|
workerNodeConnectionEntry->maintenanceConnectionsCount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -446,7 +461,8 @@ IncrementSharedConnectionCounterInternal(uint32 externalFlags,
|
||||||
currentConnectionsCount = workerNodeConnectionEntry->regularConnectionsCount;
|
currentConnectionsCount = workerNodeConnectionEntry->regularConnectionsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool remoteNodeLimitExceeded = currentConnectionsCount + 1 > currentConnectionsLimit;
|
bool remoteNodeLimitExceeded = currentConnectionsCount + 1 >
|
||||||
|
currentConnectionsLimit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For local nodes, solely relying on citus.max_shared_pool_size or
|
* For local nodes, solely relying on citus.max_shared_pool_size or
|
||||||
|
@ -512,7 +528,7 @@ IncrementSharedConnectionCounterInternal(uint32 externalFlags,
|
||||||
void
|
void
|
||||||
DecrementSharedConnectionCounter(uint32 externalFlags, const char *hostname, int port)
|
DecrementSharedConnectionCounter(uint32 externalFlags, const char *hostname, int port)
|
||||||
{
|
{
|
||||||
// TODO: possible bug, remove this check?
|
/* TODO: possible bug, remove this check? */
|
||||||
if (isConnectionThrottlingDisabled(externalFlags))
|
if (isConnectionThrottlingDisabled(externalFlags))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -526,6 +542,7 @@ DecrementSharedConnectionCounter(uint32 externalFlags, const char *hostname, int
|
||||||
WakeupWaiterBackendsForSharedConnection();
|
WakeupWaiterBackendsForSharedConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DecrementSharedConnectionCounterInternal(uint32 externalFlags,
|
DecrementSharedConnectionCounterInternal(uint32 externalFlags,
|
||||||
const char *hostname,
|
const char *hostname,
|
||||||
|
@ -533,9 +550,11 @@ DecrementSharedConnectionCounterInternal(uint32 externalFlags,
|
||||||
Oid database)
|
Oid database)
|
||||||
{
|
{
|
||||||
bool workerNodeEntryFound = false;
|
bool workerNodeEntryFound = false;
|
||||||
SharedWorkerNodeConnStatsHashKey workerNodeKey = PrepareWorkerNodeHashKey(hostname, port);
|
SharedWorkerNodeConnStatsHashKey workerNodeKey = PrepareWorkerNodeHashKey(hostname,
|
||||||
|
port);
|
||||||
SharedWorkerNodeConnStatsHashEntry *workerNodeConnectionEntry =
|
SharedWorkerNodeConnStatsHashEntry *workerNodeConnectionEntry =
|
||||||
hash_search(SharedWorkerNodeConnStatsHash, &workerNodeKey, HASH_FIND, &workerNodeEntryFound);
|
hash_search(SharedWorkerNodeConnStatsHash, &workerNodeKey, HASH_FIND,
|
||||||
|
&workerNodeEntryFound);
|
||||||
|
|
||||||
/* this worker node is removed or updated, no need to care */
|
/* this worker node is removed or updated, no need to care */
|
||||||
if (!workerNodeEntryFound)
|
if (!workerNodeEntryFound)
|
||||||
|
@ -609,7 +628,8 @@ DecrementSharedConnectionCounterInternal(uint32 externalFlags,
|
||||||
|
|
||||||
if (workerNodeDatabaseEntry->count == 0)
|
if (workerNodeDatabaseEntry->count == 0)
|
||||||
{
|
{
|
||||||
hash_search(SharedWorkerNodeDatabaseConnStatsHash, &workerNodeDatabaseKey, HASH_REMOVE, NULL);
|
hash_search(SharedWorkerNodeDatabaseConnStatsHash, &workerNodeDatabaseKey,
|
||||||
|
HASH_REMOVE, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,12 +727,15 @@ SharedConnectionStatsShmemSize(void)
|
||||||
size = add_size(size, sizeof(ConnectionStatsSharedData));
|
size = add_size(size, sizeof(ConnectionStatsSharedData));
|
||||||
|
|
||||||
Size workerNodeConnHashSize = hash_estimate_size(MaxWorkerNodesTracked,
|
Size workerNodeConnHashSize = hash_estimate_size(MaxWorkerNodesTracked,
|
||||||
sizeof(SharedWorkerNodeConnStatsHashEntry));
|
sizeof(
|
||||||
|
SharedWorkerNodeConnStatsHashEntry));
|
||||||
|
|
||||||
size = add_size(size, workerNodeConnHashSize);
|
size = add_size(size, workerNodeConnHashSize);
|
||||||
|
|
||||||
Size workerNodeDatabaseConnSize = hash_estimate_size(MaxWorkerNodesTracked * MaxDatabasesPerWorkerNodesTracked,
|
Size workerNodeDatabaseConnSize = hash_estimate_size(MaxWorkerNodesTracked *
|
||||||
sizeof(SharedWorkerNodeDatabaseConnStatsHashEntry));
|
MaxDatabasesPerWorkerNodesTracked,
|
||||||
|
sizeof(
|
||||||
|
SharedWorkerNodeDatabaseConnStatsHashEntry));
|
||||||
|
|
||||||
size = add_size(size, workerNodeDatabaseConnSize);
|
size = add_size(size, workerNodeDatabaseConnSize);
|
||||||
|
|
||||||
|
@ -760,9 +783,11 @@ SharedConnectionStatsShmemInit(void)
|
||||||
|
|
||||||
/* create (hostname, port) -> [counter] */
|
/* create (hostname, port) -> [counter] */
|
||||||
HASHCTL sharedWorkerNodeConnStatsHashInfo;
|
HASHCTL sharedWorkerNodeConnStatsHashInfo;
|
||||||
memset(&sharedWorkerNodeConnStatsHashInfo, 0, sizeof(sharedWorkerNodeConnStatsHashInfo));
|
memset(&sharedWorkerNodeConnStatsHashInfo, 0,
|
||||||
|
sizeof(sharedWorkerNodeConnStatsHashInfo));
|
||||||
sharedWorkerNodeConnStatsHashInfo.keysize = sizeof(SharedWorkerNodeConnStatsHashKey);
|
sharedWorkerNodeConnStatsHashInfo.keysize = sizeof(SharedWorkerNodeConnStatsHashKey);
|
||||||
sharedWorkerNodeConnStatsHashInfo.entrysize = sizeof(SharedWorkerNodeConnStatsHashEntry);
|
sharedWorkerNodeConnStatsHashInfo.entrysize =
|
||||||
|
sizeof(SharedWorkerNodeConnStatsHashEntry);
|
||||||
sharedWorkerNodeConnStatsHashInfo.hash = SharedConnectionHashHash;
|
sharedWorkerNodeConnStatsHashInfo.hash = SharedConnectionHashHash;
|
||||||
sharedWorkerNodeConnStatsHashInfo.match = SharedConnectionHashCompare;
|
sharedWorkerNodeConnStatsHashInfo.match = SharedConnectionHashCompare;
|
||||||
SharedWorkerNodeConnStatsHash =
|
SharedWorkerNodeConnStatsHash =
|
||||||
|
@ -774,13 +799,17 @@ SharedConnectionStatsShmemInit(void)
|
||||||
|
|
||||||
/* create (hostname, port, database) -> [counter] */
|
/* create (hostname, port, database) -> [counter] */
|
||||||
HASHCTL sharedWorkerNodeDatabaseConnStatsHashInfo;
|
HASHCTL sharedWorkerNodeDatabaseConnStatsHashInfo;
|
||||||
memset(&sharedWorkerNodeDatabaseConnStatsHashInfo, 0, sizeof(sharedWorkerNodeDatabaseConnStatsHashInfo));
|
memset(&sharedWorkerNodeDatabaseConnStatsHashInfo, 0,
|
||||||
sharedWorkerNodeDatabaseConnStatsHashInfo.keysize = sizeof(SharedWorkerNodeDatabaseConnStatsHashKey);
|
sizeof(sharedWorkerNodeDatabaseConnStatsHashInfo));
|
||||||
sharedWorkerNodeDatabaseConnStatsHashInfo.entrysize = sizeof(SharedWorkerNodeDatabaseConnStatsHashEntry);
|
sharedWorkerNodeDatabaseConnStatsHashInfo.keysize =
|
||||||
|
sizeof(SharedWorkerNodeDatabaseConnStatsHashKey);
|
||||||
|
sharedWorkerNodeDatabaseConnStatsHashInfo.entrysize =
|
||||||
|
sizeof(SharedWorkerNodeDatabaseConnStatsHashEntry);
|
||||||
sharedWorkerNodeDatabaseConnStatsHashInfo.hash = SharedWorkerNodeDatabaseHashHash;
|
sharedWorkerNodeDatabaseConnStatsHashInfo.hash = SharedWorkerNodeDatabaseHashHash;
|
||||||
sharedWorkerNodeDatabaseConnStatsHashInfo.match = SharedWorkerNodeDatabaseHashCompare;
|
sharedWorkerNodeDatabaseConnStatsHashInfo.match = SharedWorkerNodeDatabaseHashCompare;
|
||||||
|
|
||||||
int sharedWorkerNodeDatabaseConnStatsHashSize = MaxWorkerNodesTracked * MaxDatabasesPerWorkerNodesTracked;
|
int sharedWorkerNodeDatabaseConnStatsHashSize = MaxWorkerNodesTracked *
|
||||||
|
MaxDatabasesPerWorkerNodesTracked;
|
||||||
SharedWorkerNodeDatabaseConnStatsHash =
|
SharedWorkerNodeDatabaseConnStatsHash =
|
||||||
ShmemInitHash("Shared Conn Per Database. Stats Hash",
|
ShmemInitHash("Shared Conn Per Database. Stats Hash",
|
||||||
sharedWorkerNodeDatabaseConnStatsHashSize,
|
sharedWorkerNodeDatabaseConnStatsHashSize,
|
||||||
|
@ -889,7 +918,9 @@ ShouldWaitForConnection(int currentConnectionCount)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SharedWorkerNodeConnStatsHashKey PrepareWorkerNodeHashKey(const char *hostname, int port)
|
|
||||||
|
static SharedWorkerNodeConnStatsHashKey
|
||||||
|
PrepareWorkerNodeHashKey(const char *hostname, int port)
|
||||||
{
|
{
|
||||||
SharedWorkerNodeConnStatsHashKey key;
|
SharedWorkerNodeConnStatsHashKey key;
|
||||||
strlcpy(key.hostname, hostname, MAX_NODE_LENGTH);
|
strlcpy(key.hostname, hostname, MAX_NODE_LENGTH);
|
||||||
|
@ -903,7 +934,9 @@ static SharedWorkerNodeConnStatsHashKey PrepareWorkerNodeHashKey(const char *hos
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SharedWorkerNodeDatabaseConnStatsHashKey PrepareWorkerNodeDatabaseHashKey(const char *hostname,
|
|
||||||
|
static SharedWorkerNodeDatabaseConnStatsHashKey
|
||||||
|
PrepareWorkerNodeDatabaseHashKey(const char *hostname,
|
||||||
int port,
|
int port,
|
||||||
Oid database)
|
Oid database)
|
||||||
{
|
{
|
||||||
|
@ -925,10 +958,12 @@ SharedConnectionHashHash(const void *key, Size keysize)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint32
|
static uint32
|
||||||
SharedWorkerNodeDatabaseHashHash(const void *key, Size keysize)
|
SharedWorkerNodeDatabaseHashHash(const void *key, Size keysize)
|
||||||
{
|
{
|
||||||
SharedWorkerNodeDatabaseConnStatsHashKey *entry = (SharedWorkerNodeDatabaseConnStatsHashKey *) key;
|
SharedWorkerNodeDatabaseConnStatsHashKey *entry =
|
||||||
|
(SharedWorkerNodeDatabaseConnStatsHashKey *) key;
|
||||||
uint32 hash = string_hash(entry->workerNodeKey.hostname, NAMEDATALEN);
|
uint32 hash = string_hash(entry->workerNodeKey.hostname, NAMEDATALEN);
|
||||||
hash = hash_combine(hash, hash_uint32(entry->workerNodeKey.port));
|
hash = hash_combine(hash, hash_uint32(entry->workerNodeKey.port));
|
||||||
hash = hash_combine(hash, hash_uint32(entry->database));
|
hash = hash_combine(hash, hash_uint32(entry->database));
|
||||||
|
@ -947,20 +982,27 @@ SharedConnectionHashCompare(const void *a, const void *b, Size keysize)
|
||||||
ca->port != cb->port;
|
ca->port != cb->port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
SharedWorkerNodeDatabaseHashCompare(const void *a, const void *b, Size keysize)
|
SharedWorkerNodeDatabaseHashCompare(const void *a, const void *b, Size keysize)
|
||||||
{
|
{
|
||||||
SharedWorkerNodeDatabaseConnStatsHashKey *ca = (SharedWorkerNodeDatabaseConnStatsHashKey *) a;
|
SharedWorkerNodeDatabaseConnStatsHashKey *ca =
|
||||||
SharedWorkerNodeDatabaseConnStatsHashKey *cb = (SharedWorkerNodeDatabaseConnStatsHashKey *) b;
|
(SharedWorkerNodeDatabaseConnStatsHashKey *) a;
|
||||||
|
SharedWorkerNodeDatabaseConnStatsHashKey *cb =
|
||||||
|
(SharedWorkerNodeDatabaseConnStatsHashKey *) b;
|
||||||
|
|
||||||
return strncmp(ca->workerNodeKey.hostname, cb->workerNodeKey.hostname, MAX_NODE_LENGTH) != 0 ||
|
return strncmp(ca->workerNodeKey.hostname, cb->workerNodeKey.hostname,
|
||||||
|
MAX_NODE_LENGTH) != 0 ||
|
||||||
ca->workerNodeKey.port != cb->workerNodeKey.port ||
|
ca->workerNodeKey.port != cb->workerNodeKey.port ||
|
||||||
ca->database != cb->database;
|
ca->database != cb->database;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isConnectionThrottlingDisabled(uint32 externalFlags)
|
|
||||||
|
static bool
|
||||||
|
isConnectionThrottlingDisabled(uint32 externalFlags)
|
||||||
{
|
{
|
||||||
bool maintenanceConnection = externalFlags & MAINTENANCE_CONNECTION;
|
bool maintenanceConnection = externalFlags & MAINTENANCE_CONNECTION;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do not call Get*PoolSize() functions here, since it may read from
|
* Do not call Get*PoolSize() functions here, since it may read from
|
||||||
* the catalog and we may be in the process exit handler.
|
* the catalog and we may be in the process exit handler.
|
||||||
|
|
|
@ -1071,6 +1071,7 @@ citus_pid_for_gpid(PG_FUNCTION_ARGS)
|
||||||
PG_RETURN_INT32(ExtractProcessIdFromGlobalPID(globalPID));
|
PG_RETURN_INT32(ExtractProcessIdFromGlobalPID(globalPID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ExtractGlobalPID extracts the global process id from the application name and returns it
|
* ExtractGlobalPID extracts the global process id from the application name and returns it
|
||||||
* if the application name is not compatible with Citus' application names returns 0.
|
* if the application name is not compatible with Citus' application names returns 0.
|
||||||
|
|
|
@ -1233,4 +1233,3 @@ MetadataSyncTriggeredCheckAndReset(MaintenanceDaemonDBData *dbData)
|
||||||
|
|
||||||
return metadataSyncTriggered;
|
return metadataSyncTriggered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,14 @@ extern int GetMaxClientConnections(void);
|
||||||
extern int GetMaxSharedPoolSize(void);
|
extern int GetMaxSharedPoolSize(void);
|
||||||
extern int GetMaxMaintenanceSharedPoolSize(void);
|
extern int GetMaxMaintenanceSharedPoolSize(void);
|
||||||
extern int GetLocalSharedPoolSize(void);
|
extern int GetLocalSharedPoolSize(void);
|
||||||
extern bool TryToIncrementSharedConnectionCounter(uint32 flags, const char *hostname, int port);
|
extern bool TryToIncrementSharedConnectionCounter(uint32 flags, const char *hostname,
|
||||||
|
int port);
|
||||||
extern void WaitLoopForSharedConnection(uint32 flags, const char *hostname, int port);
|
extern void WaitLoopForSharedConnection(uint32 flags, const char *hostname, int port);
|
||||||
extern void DecrementSharedConnectionCounter(uint32 externalFlags, const char *hostname, int port);
|
extern void DecrementSharedConnectionCounter(uint32 externalFlags, const char *hostname,
|
||||||
extern void IncrementSharedConnectionCounter(uint32 flags, const char *hostname, int port);
|
int port);
|
||||||
extern int AdaptiveConnectionManagementFlag(bool connectToLocalNode, int
|
extern void IncrementSharedConnectionCounter(uint32 flags, const char *hostname,
|
||||||
activeConnectionCount);
|
int port);
|
||||||
|
extern int AdaptiveConnectionManagementFlag(bool connectToLocalNode,
|
||||||
|
int activeConnectionCount);
|
||||||
|
|
||||||
#endif /* SHARED_CONNECTION_STATS_H */
|
#endif /* SHARED_CONNECTION_STATS_H */
|
||||||
|
|
Loading…
Reference in New Issue