diff options
| author | Pavan Deolasee | 2016-02-10 11:54:18 +0000 |
|---|---|---|
| committer | Pavan Deolasee | 2016-10-18 09:57:45 +0000 |
| commit | 03ab6a54f92ba2c00b9c97e71824e6b1f5c43a07 (patch) | |
| tree | 639db20d8f9918a3d67682dd2ed67a004f26e57b | |
| parent | b45a5101a229b1051edee028b22047d6a489c5f7 (diff) | |
Do not log unnecessary node registration failures by differentiating between a
node and session registration
| -rw-r--r-- | src/gtm/main/gtm_standby.c | 2 | ||||
| -rw-r--r-- | src/gtm/recovery/register_common.c | 33 | ||||
| -rw-r--r-- | src/gtm/recovery/register_gtm.c | 3 | ||||
| -rw-r--r-- | src/include/gtm/register.h | 8 |
4 files changed, 39 insertions, 7 deletions
diff --git a/src/gtm/main/gtm_standby.c b/src/gtm/main/gtm_standby.c index bc96c32793..cc5fea758f 100644 --- a/src/gtm/main/gtm_standby.c +++ b/src/gtm/main/gtm_standby.c @@ -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; diff --git a/src/gtm/recovery/register_common.c b/src/gtm/recovery/register_common.c index ef6c0e5574..7279c5ba03 100644 --- a/src/gtm/recovery/register_common.c +++ b/src/gtm/recovery/register_common.c @@ -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 diff --git a/src/gtm/recovery/register_gtm.c b/src/gtm/recovery/register_gtm.c index 67ae760bc1..6bbb426bf0 100644 --- a/src/gtm/recovery/register_gtm.c +++ b/src/gtm/recovery/register_gtm.c @@ -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, diff --git a/src/include/gtm/register.h b/src/include/gtm/register.h index 16e46e35b6..0212a9ecf8 100644 --- a/src/include/gtm/register.h +++ b/src/include/gtm/register.h @@ -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, |
