From: Pavan Deolasee Date: Fri, 7 Dec 2018 02:52:48 +0000 (+0530) Subject: Initialise PGXCNodeIdentifier as part of multi-executor setup X-Git-Tag: XL_10_R1_1~15 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=174200db53a97aa37ef5a2d6addee49141e5a48e;p=postgres-xl.git Initialise PGXCNodeIdentifier as part of multi-executor setup We used to do this while creating a portal. It's not clear why that place was chosen by the original author, but it seems more logical to do so while setting up multi-node execution environment. This also solves the problem of a parallel worker not seeing the correct state, as reported by Virendra Kumar. --- diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index d59e9cd7f7..1c4409708b 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -181,6 +181,16 @@ static List *local_param_list = NIL; static StringInfo session_params; static StringInfo local_params; +char *PGXCNodeName = NULL; +int PGXCNodeId = 0; + +/* + * When a particular node starts up, store the node identifier in this variable + * so that we dont have to calculate it OR do a search in cache any where else + * This will have minimal impact on performance + */ +uint32 PGXCNodeIdentifier = 0; + typedef struct { NameData name; @@ -252,6 +262,7 @@ InitMultinodeExecutor(bool is_force) int count; Oid *coOids, *dnOids; MemoryContext oldcontext; + char *node_name; /* Free all the existing information first */ if (is_force) @@ -268,6 +279,11 @@ InitMultinodeExecutor(bool is_force) /* Get classified list of node Oids */ PgxcNodeGetOids(&coOids, &dnOids, &NumCoords, &NumDataNodes, true); + /* Initialise node identifier */ + node_name = str_tolower(PGXCNodeName, strlen(PGXCNodeName), DEFAULT_COLLATION_OID); + PGXCNodeIdentifier = get_pgxc_node_id(get_pgxc_nodeoid(node_name)); + pfree(node_name); + /* * Coordinator and datanode handles should be available during all the * session lifetime diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index dd45c638c4..c4a258452d 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -405,17 +405,6 @@ static bool LoadedSSL = false; static DNSServiceRef bonjour_sdref = NULL; #endif -#ifdef PGXC -char *PGXCNodeName = NULL; -int PGXCNodeId = 0; -/* - * When a particular node starts up, store the node identifier in this variable - * so that we dont have to calculate it OR do a search in cache any where else - * This will have minimal impact on performance - */ -uint32 PGXCNodeIdentifier = 0; -#endif - /* * postmaster.c - function prototypes */ diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index aa61b52de0..dffcd62624 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -237,19 +237,9 @@ CreatePortal(const char *name, bool allowDup, bool dupSilent) /* put portal in table (sets portal->name) */ PortalHashTableInsert(portal, name); -#ifdef PGXC elog(DEBUG3, "Created portal %s and inserted an entry in the has table", name); - if (PGXCNodeIdentifier == 0) - { - char *node_name; - node_name = str_tolower(PGXCNodeName, strlen(PGXCNodeName), DEFAULT_COLLATION_OID); - PGXCNodeIdentifier = get_pgxc_node_id(get_pgxc_nodeoid(node_name)); - pfree(node_name); - } -#endif - return portal; }