Some indentation/style fixes

preventConflictingFlags
Onder Kalaci 2020-04-06 12:03:19 +02:00
parent 156d12483d
commit dfe2354378
3 changed files with 18 additions and 14 deletions

View File

@ -324,7 +324,7 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
{ {
/* /*
* The caller doesn't want the connection manager to wait * The caller doesn't want the connection manager to wait
* until a connection slot is avaliable on the remote node. * until a connection slot is available on the remote node.
* In the end, we might fail to establish connection to the * In the end, we might fail to establish connection to the
* remote node as it might not have any space in * remote node as it might not have any space in
* max_connections for this connection establishment. * max_connections for this connection establishment.
@ -362,7 +362,7 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
PG_CATCH(); PG_CATCH();
{ {
/* /*
* Something went wrong, make sure to decement * Something went wrong, make sure to decrement
* here otherwise we'd leak the increment we have done for this * here otherwise we'd leak the increment we have done for this
* connection attempt. * connection attempt.
*/ */

View File

@ -37,7 +37,7 @@
/* /*
* The data structure used to store data in shared memory. This data structure only * The data structure used to store data in shared memory. This data structure is only
* used for storing the lock. The actual statistics about the connections are stored * used for storing the lock. The actual statistics about the connections are stored
* in the hashmap, which is allocated separately, as Postgres provides different APIs * in the hashmap, which is allocated separately, as Postgres provides different APIs
* for allocating hashmaps in the shared memory. * for allocating hashmaps in the shared memory.
@ -85,7 +85,7 @@ typedef struct SharedConnStatsHashEntry
*/ */
int MaxSharedPoolSize = 0; int MaxSharedPoolSize = 0;
/* the following two structs used for accessing shared memory */ /* the following two structs are used for accessing shared memory */
static HTAB *SharedConnStatsHash = NULL; static HTAB *SharedConnStatsHash = NULL;
static ConnectionStatsSharedData *ConnectionStatsSharedState = NULL; static ConnectionStatsSharedData *ConnectionStatsSharedState = NULL;
@ -185,7 +185,7 @@ RemoveAllSharedConnectionEntriesForNode(char *hostname, int port)
connKey.port = port; connKey.port = port;
strlcpy(connKey.hostname, hostname, MAX_NODE_LENGTH); strlcpy(connKey.hostname, hostname, MAX_NODE_LENGTH);
/* we're reading all shared connections, prevent any changes */ /* we're modifying the hashmap, prevent any concurrent access */
LockConnectionSharedMemory(LW_EXCLUSIVE); LockConnectionSharedMemory(LW_EXCLUSIVE);
bool entryFound = false; bool entryFound = false;
@ -269,11 +269,9 @@ TryToIncrementSharedConnectionCounter(const char *hostname, int port)
LockConnectionSharedMemory(LW_EXCLUSIVE); LockConnectionSharedMemory(LW_EXCLUSIVE);
/* /*
* Note that while holding a spinlock, it would not allowed to use HASH_ENTER_NULL * As the hash map is allocated in shared memory, it doesn't rely on palloc for
* if the entries in SharedConnStatsHash were allocated via palloc (as palloc * memory allocation, so we could get NULL via HASH_ENTER_NULL. That's why we prefer
* might throw OOM errors). However, in this case we're safe as the hash map is * continuing the execution instead of throwing an error.
* allocated in shared memory, which doesn't rely on palloc for memory allocation.
* This is already asserted in hash_search() by Postgres.
*/ */
bool entryFound = false; bool entryFound = false;
SharedConnStatsHashEntry *connectionEntry = SharedConnStatsHashEntry *connectionEntry =

View File

@ -2453,9 +2453,9 @@ ManageWorkerPool(WorkerPool *workerPool)
/* /*
* ConnectionThrottlingRequired contains the logic to decide whether a new connection * CanUseOptionalConnection contains the logic to decide whether a new connection
* can be considered as optional or not. When the function return true, the connection * can be considered as optional or not. When the function returns true, the connection
* can be established with optinal flag, else it should not be an optional connection. * can be established with optional flag, else it should not be an optional connection.
*/ */
static bool static bool
CanUseOptionalConnection(WorkerPool *workerPool) CanUseOptionalConnection(WorkerPool *workerPool)
@ -2483,7 +2483,13 @@ CanUseOptionalConnection(WorkerPool *workerPool)
} }
else if (UseConnectionPerPlacement()) else if (UseConnectionPerPlacement())
{ {
/* user wants one connection per placement, so no throttling is desired */ /*
* User wants one connection per placement, so no throttling is desired.
* The primary reason for this is that allowing multiple backends to use
* connection per placement could lead to unresolved self deadlocks. In other
* words, each backend may stuck waiting for other backends to get a slot
* in the shared connection counters.
*/
return false; return false;
} }