You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(28) |
Jun
(12) |
Jul
(11) |
Aug
(12) |
Sep
(5) |
Oct
(19) |
Nov
(14) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(18) |
Feb
(30) |
Mar
(115) |
Apr
(89) |
May
(50) |
Jun
(44) |
Jul
(22) |
Aug
(13) |
Sep
(11) |
Oct
(30) |
Nov
(28) |
Dec
(39) |
2012 |
Jan
(38) |
Feb
(18) |
Mar
(43) |
Apr
(91) |
May
(108) |
Jun
(46) |
Jul
(37) |
Aug
(44) |
Sep
(33) |
Oct
(29) |
Nov
(36) |
Dec
(15) |
2013 |
Jan
(35) |
Feb
(611) |
Mar
(5) |
Apr
(55) |
May
(30) |
Jun
(28) |
Jul
(458) |
Aug
(34) |
Sep
(9) |
Oct
(39) |
Nov
(22) |
Dec
(32) |
2014 |
Jan
(16) |
Feb
(16) |
Mar
(42) |
Apr
(179) |
May
(7) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(4) |
Oct
|
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
(2) |
2
(3) |
3
|
4
(2) |
5
(3) |
6
(2) |
7
(8) |
8
(12) |
9
|
10
|
11
(17) |
12
(16) |
13
(4) |
14
(3) |
15
(5) |
16
|
17
|
18
(1) |
19
(3) |
20
(2) |
21
(1) |
22
(1) |
23
|
24
|
25
(3) |
26
(1) |
27
|
28
|
29
|
30
|
From: Abbas B. <ga...@us...> - 2011-04-01 18:17:46
|
Project "Postgres-XC". The branch, master has been updated via f738280c29b0e50348a8b0940679595534220e24 (commit) from 91466a5b79ebd8aea0b6313704654b0a1b7818ac (commit) - Log ----------------------------------------------------------------- commit f738280c29b0e50348a8b0940679595534220e24 Author: Abbas <abb...@en...> Date: Fri Apr 1 22:40:29 2011 +0500 This patch fixes bug ID 3136257. The test case was trying to prepare a transaction after a fetch from a cursor inside a transaction. The way cursors are handled in XC, a FETCH can leave one of the datanodes in DN_CONNECTION_STATE_QUERY. This fact was being ignored by pgxc_all_handles_send_query, which would error out if any of the data nodes is in any state other than DN_CONNECTION_STATE_IDLE, where as the correct handling in this case is to call BufferConnection and continue. Next there was an error in ExecEndRemoteQuery. PGXCNodePrepare called in response to PREPARE TRANSACTION would call release_handles to release all data node connections and coordinator connections back to pool. Later when ExecEndRemoteQuery would try to close cursors, it would find a -1 in sock of all data node connections and hence the system would report that it was unable to close cursors. This patch adds correct handling while closing cursors in ExecEndRemoteQuery. diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 7c9ec5b..cf38041 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -3470,9 +3470,17 @@ do_query(RemoteQueryState *node) int i = 0; if (pgxc_node_receive(regular_conn_count, connections, NULL)) + { + pfree(connections); + if (primaryconnection) + pfree(primaryconnection); + if (node->cursor_connections) + pfree(node->cursor_connections); + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Failed to read response from data nodes"))); + } /* * Handle input from the data nodes. * If we got a RESPONSE_DATAROW we can break handling to wrap @@ -3631,6 +3639,7 @@ ExecRemoteQuery(RemoteQueryState *node) node->update_cursor); pfree(node->update_cursor); node->update_cursor = NULL; + pfree_pgxc_all_handles(all_dn_handles); } handle_results: @@ -3878,17 +3887,45 @@ ExecEndRemoteQuery(RemoteQueryState *node) /* * If there are active cursors close them */ - if (node->cursor) - close_node_cursors(node->cursor_connections, node->cursor_count, node->cursor); - - if (node->update_cursor) + if (node->cursor || node->update_cursor) { - PGXCNodeAllHandles *all_dn_handles = get_exec_connections(node, NULL, EXEC_ON_DATANODES); - close_node_cursors(all_dn_handles->datanode_handles, - all_dn_handles->dn_conn_count, - node->update_cursor); - pfree(node->update_cursor); - node->update_cursor = NULL; + PGXCNodeAllHandles *all_handles = NULL; + PGXCNodeHandle **cur_handles; + bool bFree = false; + int nCount; + int i; + + cur_handles = node->cursor_connections; + nCount = node->cursor_count; + + for(i=0;i<node->cursor_count;i++) + { + if (node->cursor_connections == NULL || node->cursor_connections[i]->sock == -1) + { + bFree = true; + all_handles = get_exec_connections(node, NULL, EXEC_ON_DATANODES); + cur_handles = all_handles->datanode_handles; + nCount = all_handles->dn_conn_count; + break; + } + } + + if (node->cursor) + { + close_node_cursors(cur_handles, nCount, node->cursor); + pfree(node->cursor); + node->cursor = NULL; + } + + if (node->update_cursor) + { + close_node_cursors(cur_handles, nCount, node->update_cursor); + pfree(node->update_cursor); + node->update_cursor = NULL; + } + + if (bFree) + pfree_pgxc_all_handles(all_handles); } /* diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index 8c1de08..dcd721d 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -1832,13 +1832,12 @@ pgxc_all_handles_send_query(PGXCNodeAllHandles *pgxc_handles, const char *buffer if (pgxc_handles->primary_handle) dn_conn_count--; - /* Send to Datanodes */ - for (i = 0; i < dn_conn_count; i++) + /* Send to Datanodes */ + for (i = 0; i < dn_conn_count; i++) { if (pgxc_handles->datanode_handles[i]->state != DN_CONNECTION_STATE_IDLE) { - pgxc_handles->datanode_handles[i]->state = DN_CONNECTION_STATE_ERROR_FATAL; - continue; + BufferConnection(pgxc_handles->datanode_handles[i]); } if (pgxc_node_send_query(pgxc_handles->datanode_handles[i], buffer)) { @@ -1848,8 +1847,8 @@ pgxc_all_handles_send_query(PGXCNodeAllHandles *pgxc_handles, const char *buffer goto finish; } } - /* Send to Coordinators */ - for (i = 0; i < co_conn_count; i++) + /* Send to Coordinators */ + for (i = 0; i < co_conn_count; i++) { if (pgxc_node_send_query(pgxc_handles->coord_handles[i], buffer)) { ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 57 +++++++++++++++++++++++++++++------ src/backend/pgxc/pool/pgxcnode.c | 11 +++---- 2 files changed, 52 insertions(+), 16 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-04-01 07:32:06
|
Project "Postgres-XC". The branch, master has been updated via 91466a5b79ebd8aea0b6313704654b0a1b7818ac (commit) from 0429a889372c6db0b4b1253624601c42410cc108 (commit) - Log ----------------------------------------------------------------- commit 91466a5b79ebd8aea0b6313704654b0a1b7818ac Author: Michael P <mic...@us...> Date: Fri Apr 1 16:21:34 2011 +0900 Fix for bug 3234421: multiple user support for pooler This commit extends pooler functionalities for multiple users. Now user name used for connection string is built directly from the user name got on port of postmaster at a user connection on Coordinator. This also solves a serious security issue with passwords parameters in postgresql.conf and when building the connection string of pooler. It also avoids that passwords are written by pooler logging system. In consequence, the following GUC parameters are deleted: data_node_users, data_node_passwords, coordinator_users, coordinator_passwords. This commit is a first step for the support of session parameters. diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index e93ee7f..8c1de08 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -144,7 +144,7 @@ InitMultinodeExecutor(void) */ char * PGXCNodeConnStr(char *host, char *port, char *dbname, - char *user, char *password, char *remote_type) + char *user, char *remote_type) { char *out, connstr[256]; @@ -155,8 +155,8 @@ PGXCNodeConnStr(char *host, char *port, char *dbname, * remote type can be coordinator, datanode or application. */ num = snprintf(connstr, sizeof(connstr), - "host=%s port=%s dbname=%s user=%s password=%s options='-c remotetype=%s'", - host, port, dbname, user, password, remote_type); + "host=%s port=%s dbname=%s user=%s options='-c remotetype=%s'", + host, port, dbname, user, remote_type); /* Check for overflow */ if (num > 0 && num < sizeof(connstr)) diff --git a/src/backend/pgxc/pool/poolmgr.c b/src/backend/pgxc/pool/poolmgr.c index 28e9dce..478ba42 100644 --- a/src/backend/pgxc/pool/poolmgr.c +++ b/src/backend/pgxc/pool/poolmgr.c @@ -68,14 +68,10 @@ static MemoryContext PoolerMemoryContext = NULL; /* Connection info of Datanodes */ char *DataNodeHosts = NULL; char *DataNodePorts = NULL; -char *DataNodeUsers = NULL; -char *DataNodePwds = NULL; /* Connection info of Coordinators */ char *CoordinatorHosts = NULL; char *CoordinatorPorts = NULL; -char *CoordinatorUsers = NULL; -char *CoordinatorPwds = NULL; /* PGXC Nodes info list */ static PGXCNodeConnectionInfo *datanode_connInfos; @@ -93,15 +89,16 @@ static PoolHandle *Handle = NULL; static int is_pool_cleaning = false; static int server_fd = -1; -static void agent_init(PoolAgent *agent, const char *database); +static void agent_init(PoolAgent *agent, const char *database, const char *user_name); static void agent_destroy(PoolAgent *agent); static void agent_create(void); static void agent_handle_input(PoolAgent *agent, StringInfo s); -static DatabasePool *create_database_pool(const char *database); +static DatabasePool *create_database_pool(const char *database, const char *user_name); static void insert_database_pool(DatabasePool *pool); -static int destroy_database_pool(const char *database); -static DatabasePool *find_database_pool(const char *database); -static DatabasePool *remove_database_pool(const char *database); +static int destroy_database_pool(const char *database, const char *user_name); +static DatabasePool *find_database_pool(const char *database, const char *user_name); +static DatabasePool *find_database_pool_to_clean(const char *database, List *dn_list, List *co_list); +static DatabasePool *remove_database_pool(const char *database, const char *user_name); static int *agent_acquire_connections(PoolAgent *agent, List *datanodelist, List *coordlist); static PGXCNodePoolSlot *acquire_connection(DatabasePool *dbPool, int node, char client_conn_type); static void agent_release_connections(PoolAgent *agent, List *dn_discard, List *co_discard); @@ -352,164 +349,8 @@ PoolManagerInit() (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid list syntax for \"coordinator_ports\""))); } - - if (count == 0) - rawstring = pstrdup(DataNodeUsers); - if (count == 1) - rawstring = pstrdup(CoordinatorUsers); - - /* Parse string into list of identifiers */ - if (!SplitIdentifierString(rawstring, ',', &elemlist)) - { - if (count == 0) - /* syntax error in list */ - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"data_node_users\""))); - else - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"coordinator_users\""))); - } - - i = 0; - foreach(l, elemlist) - { - char *curuser = (char *) lfirst(l); - - connectionInfos[i].uname = pstrdup(curuser); - if (connectionInfos[i].uname == NULL) - { - ereport(ERROR, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of memory"))); - } - /* Ignore extra entries, if any */ - if (++i == num_nodes) - break; - } - list_free(elemlist); - pfree(rawstring); - - /* Validate */ - if (i == 0) - { - if (count == 0) - /* syntax error in list */ - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"data_node_users\""))); - else - /* syntax error in list */ - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"coordinator_users\""))); - } - else if (i == 1) - { - /* Copy all values from first */ - for (; i < num_nodes; i++) - { - connectionInfos[i].uname = pstrdup(connectionInfos[0].uname); - if (connectionInfos[i].uname == NULL) - { - ereport(ERROR, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of memory"))); - } - } - } - else if (i < num_nodes) - { - if (count == 0) - /* syntax error in list */ - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"data_node_users\""))); - else - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"coordinator_users\""))); - } - - if (count == 0) - rawstring = pstrdup(DataNodePwds); - if (count == 1) - rawstring = pstrdup(CoordinatorPwds); - - /* Parse string into list of identifiers */ - if (!SplitIdentifierString(rawstring, ',', &elemlist)) - { - if (count == 0) - /* syntax error in list */ - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"data_node_passwords\""))); - else - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"coordinator_passwords\""))); - } - - i = 0; - foreach(l, elemlist) - { - char *curpassword = (char *) lfirst(l); - - connectionInfos[i].password = pstrdup(curpassword); - if (connectionInfos[i].password == NULL) - { - ereport(ERROR, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of memory"))); - } - /* Ignore extra entries, if any */ - if (++i == num_nodes) - break; - } - list_free(elemlist); - pfree(rawstring); - - /* Validate */ - if (i == 0) - { - if (count == 0) - /* syntax error in list */ - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"data_node_passwords\""))); - else - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"coordinator_passwords\""))); - } - else if (i == 1) - { - /* Copy all values from first */ - for (; i < num_nodes; i++) - { - connectionInfos[i].password = pstrdup(connectionInfos[0].password); - if (connectionInfos[i].password == NULL) - { - ereport(ERROR, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of memory"))); - } - } - } - else if (i < num_nodes) - { - if (count == 0) - /* syntax error in list */ - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"data_node_passwords\""))); - else - ereport(FATAL, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"coordinator_passwords\""))); - } } + /* End of Parsing for Datanode and Coordinator Data */ PoolerLoop(); @@ -647,13 +488,14 @@ agent_create(void) * Invoked from Session process */ void -PoolManagerConnect(PoolHandle *handle, const char *database) +PoolManagerConnect(PoolHandle *handle, const char *database, const char *user_name) { int n32; char msgtype = 'c'; Assert(handle); Assert(database); + Assert(user_name); /* Save the handle */ Handle = handle; @@ -662,7 +504,7 @@ PoolManagerConnect(PoolHandle *handle, const char *database) pool_putbytes(&handle->port, &msgtype, 1); /* Message length */ - n32 = htonl(strlen(database) + 13); + n32 = htonl(strlen(database) + strlen(user_name) + 18); pool_putbytes(&handle->port, (char *) &n32, 4); /* PID number */ @@ -676,28 +518,37 @@ PoolManagerConnect(PoolHandle *handle, const char *database) /* Send database name followed by \0 terminator */ pool_putbytes(&handle->port, database, strlen(database) + 1); pool_flush(&handle->port); + + /* Length of user name string */ + n32 = htonl(strlen(user_name) + 1); + pool_putbytes(&handle->port, (char *) &n32, 4); + + /* Send user name followed by \0 terminator */ + pool_putbytes(&handle->port, user_name, strlen(user_name) + 1); + pool_flush(&handle->port); } /* * Init PoolAgent -*/ + */ static void -agent_init(PoolAgent *agent, const char *database) +agent_init(PoolAgent *agent, const char *database, const char *user_name) { Assert(agent); Assert(database); + Assert(user_name); /* disconnect if we are still connected */ if (agent->pool) agent_release_connections(agent, NULL, NULL); /* find database */ - agent->pool = find_database_pool(database); + agent->pool = find_database_pool(database, user_name); /* create if not found */ if (agent->pool == NULL) - agent->pool = create_database_pool(database); + agent->pool = create_database_pool(database, user_name); } @@ -932,6 +783,7 @@ agent_handle_input(PoolAgent * agent, StringInfo s) for (;;) { const char *database; + const char *user_name; int datanodecount; int coordcount; List *datanodelist = NIL; @@ -969,11 +821,13 @@ agent_handle_input(PoolAgent * agent, StringInfo s) agent->pid = pq_getmsgint(s, 4); len = pq_getmsgint(s, 4); database = pq_getmsgbytes(s, len); + len = pq_getmsgint(s, 4); + user_name = pq_getmsgbytes(s, len); /* * Coordinator pool is not initialized. * With that it would be impossible to create a Database by default. */ - agent_init(agent, database); + agent_init(agent, database, user_name); pq_getmsgend(s); break; case 'd': /* DISCONNECT */ @@ -1312,13 +1166,13 @@ agent_release_connections(PoolAgent *agent, List *dn_discard, List *co_discard) * error and POOL_WEXIST if poll for this database already exist. */ static DatabasePool * -create_database_pool(const char *database) +create_database_pool(const char *database, const char *user_name) { DatabasePool *databasePool; int i; /* check if exist */ - databasePool = find_database_pool(database); + databasePool = find_database_pool(database, user_name); if (databasePool) { /* already exist */ @@ -1336,8 +1190,10 @@ create_database_pool(const char *database) return NULL; } - /* Copy the database name */ ; + /* Copy the database name */ databasePool->database = pstrdup(database); + /* Copy the user name */ + databasePool->user_name = pstrdup(user_name); if (!databasePool->database) { /* out of memory */ @@ -1361,6 +1217,7 @@ create_database_pool(const char *database) (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); pfree(databasePool->database); + pfree(databasePool->user_name); pfree(databasePool); return NULL; } @@ -1378,6 +1235,7 @@ create_database_pool(const char *database) (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); pfree(databasePool->database); + pfree(databasePool->user_name); pfree(databasePool); return NULL; } @@ -1396,13 +1254,13 @@ create_database_pool(const char *database) * Destroy the pool and free memory */ static int -destroy_database_pool(const char *database) +destroy_database_pool(const char *database, const char *user_name) { DatabasePool *databasePool; int i; /* Delete from the list */ - databasePool = remove_database_pool(database); + databasePool = remove_database_pool(database, user_name); if (databasePool) { if (databasePool->dataNodePools) @@ -1421,6 +1279,7 @@ destroy_database_pool(const char *database) } /* free allocated memory */ pfree(databasePool->database); + pfree(databasePool->user_name); pfree(databasePool); return 1; } @@ -1448,10 +1307,10 @@ insert_database_pool(DatabasePool *databasePool) /* - * Find pool for specified database in the list + * Find pool for specified database and username in the list */ static DatabasePool * -find_database_pool(const char *database) +find_database_pool(const char *database, const char *user_name) { DatabasePool *databasePool; @@ -1459,8 +1318,8 @@ find_database_pool(const char *database) databasePool = databasePools; while (databasePool) { - /* if match break the loop and return */ - if (strcmp(database, databasePool->database) == 0) + if (strcmp(database, databasePool->database) == 0 && + strcmp(user_name, databasePool->user_name) == 0) break; databasePool = databasePool->next; @@ -1468,12 +1327,55 @@ find_database_pool(const char *database) return databasePool; } +/* + * Find pool to be cleaned for specified database in the list + */ +static DatabasePool * +find_database_pool_to_clean(const char *database, List *dn_list, List *co_list) +{ + DatabasePool *databasePool; + + /* Scan the list */ + databasePool = databasePools; + while (databasePool) + { + /* Check for given database name */ + if (strcmp(database, databasePool->database) == 0) + { + ListCell *nodelist_item; + + /* Check if this database pool is clean for given coordinator list */ + foreach (nodelist_item, co_list) + { + int nodenum = lfirst_int(nodelist_item); + + if (databasePool->coordNodePools && + databasePool->coordNodePools[nodenum - 1] && + databasePool->coordNodePools[nodenum - 1]->freeSize != 0) + return databasePool; + } + + /* Check if this database pool is clean for given datanode list */ + foreach (nodelist_item, dn_list) + { + int nodenum = lfirst_int(nodelist_item); + + if (databasePool->dataNodePools && + databasePool->dataNodePools[nodenum - 1] && + databasePool->dataNodePools[nodenum - 1]->freeSize != 0) + return databasePool; + } + } + databasePool = databasePool->next; + } + return databasePool; +} /* * Remove pool for specified database from the list */ static DatabasePool * -remove_database_pool(const char *database) +remove_database_pool(const char *database, const char *user_name) { DatabasePool *databasePool, *prev; @@ -1485,7 +1387,8 @@ remove_database_pool(const char *database) { /* if match break the loop and return */ - if (strcmp(database, databasePool->database) == 0) + if (strcmp(database, databasePool->database) == 0 && + strcmp(user_name, databasePool->user_name) == 0) break; prev = databasePool; databasePool = databasePool->next; @@ -1680,7 +1583,6 @@ grow_pool(DatabasePool * dbPool, int index, char client_conn_type) if (IS_PGXC_COORDINATOR) { remote_type = pstrdup("coordinator"); - } else if (IS_PGXC_DATANODE) { @@ -1692,18 +1594,15 @@ grow_pool(DatabasePool * dbPool, int index, char client_conn_type) nodePool->connstr = PGXCNodeConnStr(datanode_connInfos[index].host, datanode_connInfos[index].port, dbPool->database, - datanode_connInfos[index].uname, - datanode_connInfos[index].password, + dbPool->user_name, remote_type); else if (client_conn_type == REMOTE_CONN_COORD) nodePool->connstr = PGXCNodeConnStr(coord_connInfos[index].host, coord_connInfos[index].port, dbPool->database, - coord_connInfos[index].uname, - coord_connInfos[index].password, + dbPool->user_name, remote_type); - if (!nodePool->connstr) { pfree(nodePool); @@ -1864,7 +1763,8 @@ PoolerLoop(void) agent_destroy(agent); } while (databasePools) - if (destroy_database_pool(databasePools->database) == 0) + if (destroy_database_pool(databasePools->database, + databasePools->user_name) == 0) break; close(server_fd); exit(0); @@ -1918,74 +1818,79 @@ clean_connection(List *dn_discard, List *co_discard, const char *database) co_list[count++] = lfirst_int(nodelist_item); /* Find correct Database pool to clean */ - databasePool = find_database_pool(database); + databasePool = find_database_pool_to_clean(database, dn_discard, co_discard); - /* Database pool has not been found, it is already clean */ - if (!databasePool) - return CLEAN_CONNECTION_COMPLETED; - - /* - * Clean each Pool Correctly - * First for Datanode Pool - */ - for (count = 0; count < dn_len; count++) + while (databasePool) { - int node_num = dn_list[count]; - nodePool = databasePool->dataNodePools[node_num - 1]; + databasePool = find_database_pool_to_clean(database, dn_discard, co_discard); + + /* Database pool has not been found, cleaning is over */ + if (!databasePool) + break; - if (nodePool) + /* + * Clean each Pool Correctly + * First for Datanode Pool + */ + for (count = 0; count < dn_len; count++) { - /* Check if connections are in use */ - if (nodePool->freeSize != nodePool->size) - { - elog(WARNING, "Pool of Database %s is using Datanode %d connections", - databasePool->database, node_num); - res = CLEAN_CONNECTION_NOT_COMPLETED; - } + int node_num = dn_list[count]; + nodePool = databasePool->dataNodePools[node_num - 1]; - /* Destroy connections currently in Node Pool */ - if (nodePool->slot) + if (nodePool) { - for (i = 0; i < nodePool->freeSize; i++) - destroy_slot(nodePool->slot[i]); + /* Check if connections are in use */ + if (nodePool->freeSize != nodePool->size) + { + elog(WARNING, "Pool of Database %s is using Datanode %d connections", + databasePool->database, node_num); + res = CLEAN_CONNECTION_NOT_COMPLETED; + } + + /* Destroy connections currently in Node Pool */ + if (nodePool->slot) + { + for (i = 0; i < nodePool->freeSize; i++) + destroy_slot(nodePool->slot[i]); - /* Move slots in use at the beginning of Node Pool array */ - for (i = nodePool->freeSize; i < nodePool->size; i++ ) - nodePool->slot[i - nodePool->freeSize] = nodePool->slot[i]; + /* Move slots in use at the beginning of Node Pool array */ + for (i = nodePool->freeSize; i < nodePool->size; i++ ) + nodePool->slot[i - nodePool->freeSize] = nodePool->slot[i]; + } + nodePool->size -= nodePool->freeSize; + nodePool->freeSize = 0; } - nodePool->size -= nodePool->freeSize; - nodePool->freeSize = 0; } - } - - /* Then for Coordinators */ - for (count = 0; count < co_len; count++) - { - int node_num = co_list[count]; - nodePool = databasePool->coordNodePools[node_num - 1]; - if (nodePool) + /* Then for Coordinators */ + for (count = 0; count < co_len; count++) { - /* Check if connections are in use */ - if (nodePool->freeSize != nodePool->size) - { - elog(WARNING, "Pool of Database %s is using Coordinator %d connections", - databasePool->database, node_num); - res = CLEAN_CONNECTION_NOT_COMPLETED; - } + int node_num = co_list[count]; + nodePool = databasePool->coordNodePools[node_num - 1]; - /* Destroy connections currently in Node Pool */ - if (nodePool->slot) + if (nodePool) { - for (i = 0; i < nodePool->freeSize; i++) - destroy_slot(nodePool->slot[i]); + /* Check if connections are in use */ + if (nodePool->freeSize != nodePool->size) + { + elog(WARNING, "Pool of Database %s is using Coordinator %d connections", + databasePool->database, node_num); + res = CLEAN_CONNECTION_NOT_COMPLETED; + } - /* Move slots in use at the beginning of Node Pool array */ - for (i = nodePool->freeSize; i < nodePool->size; i++ ) - nodePool->slot[i - nodePool->freeSize] = nodePool->slot[i]; + /* Destroy connections currently in Node Pool */ + if (nodePool->slot) + { + for (i = 0; i < nodePool->freeSize; i++) + destroy_slot(nodePool->slot[i]); + + /* Move slots in use at the beginning of Node Pool array */ + for (i = nodePool->freeSize; i < nodePool->size; i++ ) + nodePool->slot[i - nodePool->freeSize] = nodePool->slot[i]; + } + nodePool->size -= nodePool->freeSize; + nodePool->freeSize = 0; } - nodePool->size -= nodePool->freeSize; - nodePool->freeSize = 0; } } diff --git a/src/backend/pgxc/pool/poolutils.c b/src/backend/pgxc/pool/poolutils.c index 32cdfea..24a5c72 100644 --- a/src/backend/pgxc/pool/poolutils.c +++ b/src/backend/pgxc/pool/poolutils.c @@ -36,6 +36,8 @@ * Use of CLEAN CONNECTION is limited to a super user. * It is advised to clean connections before shutting down a Node or drop a Database. * + * Pool cleaning is done for all the users of a given database. + * * SQL query synopsis is as follows: * CLEAN CONNECTION TO * (COORDINATOR num | DATANODE num | ALL {FORCE}) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 8bc77ea..552b0d8 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -3415,7 +3415,7 @@ BackendStartup(Port *port) if (IS_PGXC_COORDINATOR) { /* User is authenticated and dbname is known at this point */ - PoolManagerConnect(pool_handle, port->database_name); + PoolManagerConnect(pool_handle, port->database_name, port->user_name); InitGTM(); } #endif diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index cb0adb9..0b2c9dd 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -353,6 +353,9 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid) } else { +#ifdef PGXC + if (IS_PGXC_DATANODE || !IsConnFromCoord()) +#endif /* Shouldn't be trying to remove a live transaction here */ Assert(!TransactionIdIsValid(proc->xid)); } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index a184866..c8648ee 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -2819,26 +2819,6 @@ static struct config_string ConfigureNamesString[] = }, { - {"data_node_users", PGC_POSTMASTER, DATA_NODES, - gettext_noop("User names or addresses of data nodes."), - gettext_noop("Comma separated list or single value, " - "if user names are the same on all data nodes") - }, - &DataNodeUsers, - "postgres", NULL, NULL - }, - - { - {"data_node_passwords", PGC_POSTMASTER, DATA_NODES, - gettext_noop("Passwords of data nodes."), - gettext_noop("Comma separated list or single value, " - "if passwords are the same on all data nodes") - }, - &DataNodePwds, - "postgres", NULL, NULL - }, - - { {"gtm_host", PGC_POSTMASTER, GTM, gettext_noop("Host name or address of GTM"), NULL @@ -2867,26 +2847,6 @@ static struct config_string ConfigureNamesString[] = "5432", NULL, NULL }, - { - {"coordinator_users", PGC_POSTMASTER, COORDINATORS, - gettext_noop("User names or addresses of Coordinators."), - gettext_noop("Comma separated list or single value, " - "if user names are the same on all Coordinators") - }, - &CoordinatorUsers, - "postgres", NULL, NULL - }, - - { - {"coordinator_passwords", PGC_POSTMASTER, COORDINATORS, - gettext_noop("Passwords of Coordinators."), - gettext_noop("Comma separated list or single value, " - "if passwords are the same on all Coordinators") - }, - &CoordinatorPwds, - "postgres", NULL, NULL - }, - #endif #ifdef USE_SSL { diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 83c54d4..24bc2fa 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -542,10 +542,6 @@ # (change requires restart) #data_node_ports = '15432,25432' # Port numbers of data nodes # (change requires restart) -#data_node_users = 'postgres' # User names of data nodes - # (change requires restart) -#data_node_passwords = 'postgres' # Passwords of data nodes - # (change requires restart) #primary_data_node = 1 # Which data node to use first for # replicated writes @@ -564,10 +560,6 @@ # (change require restart) #coordinator_ports = '5432' # Port numbers of Coordinators # (change require restart) -#coordinator_users = 'postgres' # User names of Coordinators - # (change requires restart) -#coordinator_passwords = 'postgres' # Passwords of Coordinators - # (change requires restart) #------------------------------------------------------------------------------ # GTM CONNECTION diff --git a/src/include/pgxc/pgxcnode.h b/src/include/pgxc/pgxcnode.h index 321e49c..007e1dc 100644 --- a/src/include/pgxc/pgxcnode.h +++ b/src/include/pgxc/pgxcnode.h @@ -94,7 +94,7 @@ extern void InitMultinodeExecutor(void); /* Open/close connection routines (invoked from Pool Manager) */ extern char *PGXCNodeConnStr(char *host, char *port, char *dbname, char *user, - char *password, char *remote_type); + char *remote_type); extern NODE_CONNECTION *PGXCNodeConnect(char *connstr); extern void PGXCNodeClose(NODE_CONNECTION * conn); extern int PGXCNodeConnected(NODE_CONNECTION * conn); diff --git a/src/include/pgxc/poolmgr.h b/src/include/pgxc/poolmgr.h index 0ae3cc2..7e53b48 100644 --- a/src/include/pgxc/poolmgr.h +++ b/src/include/pgxc/poolmgr.h @@ -28,8 +28,6 @@ typedef struct { char *host; char *port; - char *uname; - char *password; } PGXCNodeConnectionInfo; /* Connection pool entry */ @@ -51,8 +49,8 @@ typedef struct /* All pools for specified database */ typedef struct databasepool { - Oid databaseId; char *database; + char *user_name; PGXCNodePool **dataNodePools; /* one for each Datanode */ PGXCNodePool **coordNodePools; /* one for each Coordinator */ struct databasepool *next; @@ -89,13 +87,9 @@ extern bool PersistentConnections; extern char *DataNodeHosts; extern char *DataNodePorts; -extern char *DataNodeUsers; -extern char *DataNodePwds; extern char *CoordinatorHosts; extern char *CoordinatorPorts; -extern char *CoordinatorUsers; -extern char *CoordinatorPwds; /* Initialize internal structures */ extern int PoolManagerInit(void); @@ -129,7 +123,7 @@ extern void PoolManagerDisconnect(PoolHandle *handle); * for subsequent calls. Associate session with specified database and * initialize respective connection pool */ -extern void PoolManagerConnect(PoolHandle *handle, const char *database); +extern void PoolManagerConnect(PoolHandle *handle, const char *database, const char *user_name); /* Get pooled connections */ extern int *PoolManagerGetConnections(List *datanodelist, List *coordlist); ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/pgxcnode.c | 6 +- src/backend/pgxc/pool/poolmgr.c | 393 ++++++++++--------------- src/backend/pgxc/pool/poolutils.c | 2 + src/backend/postmaster/postmaster.c | 2 +- src/backend/storage/ipc/procarray.c | 3 + src/backend/utils/misc/guc.c | 40 --- src/backend/utils/misc/postgresql.conf.sample | 8 - src/include/pgxc/pgxcnode.h | 2 +- src/include/pgxc/poolmgr.h | 10 +- 9 files changed, 161 insertions(+), 305 deletions(-) hooks/post-receive -- Postgres-XC |