Do not log unnecessary node registration failures by differentiating between a
authorPavan Deolasee <[email protected]>
Wed, 10 Feb 2016 11:54:18 +0000 (17:24 +0530)
committerPavan Deolasee <[email protected]>
Wed, 10 Feb 2016 11:54:18 +0000 (17:24 +0530)
node and session registration

src/gtm/main/gtm_standby.c
src/gtm/recovery/register_common.c
src/gtm/recovery/register_gtm.c
src/include/gtm/register.h

index bc96c327938888acff0965ac3a149386e19d0186..cc5fea758f977365e2ca2cf9deefe46ff1cdbc71 100644 (file)
@@ -221,7 +221,7 @@ gtm_standby_restore_node(void)
                if (Recovery_PGXCNodeRegister(data[i].type, data[i].nodename, data[i].port,
                                         data[i].proxyname, data[i].status,
                                         data[i].ipaddress, data[i].datafolder, true,
-                                        -1 /* dummy socket */) != 0)
+                                        -1 /* dummy socket */, false) != 0)
                {
                        rc = 0;
                        goto finished;
index ef6c0e5574d1d286fadb677a5cb350205ca5bccd..7279c5ba0398feebaf52fde6113394372ee82053 100644 (file)
@@ -257,12 +257,35 @@ pgxcnode_add_info(GTM_PGXCNodeInfo *nodeinfo)
                {
                        if (curr_nodeinfo->status == NODE_CONNECTED)
                        {
-                               GTM_RWLockRelease(&PGXCNodesLock);
-                               ereport(LOG,
+                               /*
+                                * There are two ways nodes get registered on the GTM, either
+                                * via ClusterMonitor or when a distribution session is
+                                * started. We differentiate between them. While its okay to
+                                * see duplicate messages for session registration or a session
+                                * registration message when the node is already registered by
+                                * the ClusterMonitor. Otherwise, return an error.
+                                *
+                                * The session registration is also converted into node
+                                * registration if the second message comes late
+                                */
+                               if (!curr_nodeinfo->is_session && !nodeinfo->is_session)
+                                       ereport(LOG,
                                                (EEXIST,
                                                 errmsg("Node with the given ID number already exists - %s %d:%d",
                                                        nodeinfo->nodename, nodeinfo->status,
                                                        nodeinfo->type )));
+                               else if (curr_nodeinfo->is_session && !nodeinfo->is_session)
+                               {
+                                       curr_nodeinfo->is_session = false;
+                                       GTM_RWLockRelease(&PGXCNodesLock);
+                                       return 0;
+                               }
+                               else if (!curr_nodeinfo->is_session && nodeinfo->is_session)
+                               {
+                                       GTM_RWLockRelease(&PGXCNodesLock);
+                                       return 0;
+                               }
+                               GTM_RWLockRelease(&PGXCNodesLock);
                                return EEXIST;
                        }
                        else
@@ -391,7 +414,8 @@ Recovery_PGXCNodeRegister(GTM_PGXCNodeType  type,
                                                  char                  *ipaddress,
                                                  char                  *datafolder,
                                                  bool                  in_recovery,
-                                                 int                   socket)
+                                                 int                   socket,
+                                                 bool                  is_session)
 {
        GTM_PGXCNodeInfo *nodeinfo = NULL;
        int errcode = 0;
@@ -418,6 +442,7 @@ Recovery_PGXCNodeRegister(GTM_PGXCNodeType  type,
        nodeinfo->socket = socket;
        nodeinfo->reported_xmin = InvalidGlobalTransactionId;
        nodeinfo->reported_xmin_time = GTM_TimestampGetCurrent();
+       nodeinfo->is_session = is_session;
 
        elog(DEBUG1, "Recovery_PGXCNodeRegister Request info: type=%d, nodename=%s, port=%d," \
                          "datafolder=%s, ipaddress=%s, status=%d",
@@ -757,7 +782,7 @@ Recovery_PGXCNodeRegisterCoordProcess(char *coord_node, int coord_procid,
        {
                int errcode = Recovery_PGXCNodeRegister(GTM_NODE_COORDINATOR, coord_node, 0, NULL,
                                                                          NODE_CONNECTED,
-                                                                         NULL, NULL, false, 0);
+                                                                         NULL, NULL, false, 0, true);
 
                /*
                 * If another thread registers before we get a chance, just look for
index 67ae760bc1f1876dff80dc7889b56a1f2847ae1d..6bbb426bf0d83625ed9228df4f78a25323ed9768 100644 (file)
@@ -163,7 +163,8 @@ ProcessPGXCNodeRegister(Port *myport, StringInfo message, bool is_backup)
 
        if (Recovery_PGXCNodeRegister(type, node_name, port,
                                                                  proxyname, status,
-                                                                 ipaddress, datafolder, false, myport->sock))
+                                                                 ipaddress, datafolder, false, myport->sock,
+                                                                 false))
        {
                ereport(ERROR,
                                (EINVAL,
index 16e46e35b64cad54720e9d62d63b7484244420c3..0212a9ecf834763014c3f3b7162c064d4e06c10d 100644 (file)
@@ -73,6 +73,11 @@ typedef struct GTM_PGXCNodeInfo
        GTM_PGXCSession *sessions;
        GTM_RWLock              node_lock;      /* Lock on this structure */
        int                     socket;         /* socket number used for registration */
+       bool                    is_session;     /* 
+                                                                        * entry added by node registration (false
+                                                                        * if it was added because of session
+                                                                        * registration
+                                                                        */
 } GTM_PGXCNodeInfo;
 
 
@@ -90,7 +95,8 @@ int Recovery_PGXCNodeRegister(GTM_PGXCNodeType        type,
                                char                    *ipaddress,
                                char                    *datafolder,
                                bool                    in_recovery,
-                               int                     socket);
+                               int                     socket,
+                               bool            is_session);
 int Recovery_PGXCNodeUnregister(GTM_PGXCNodeType type,
                                                                char *node_name,
                                                                bool in_recovery,