You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hawq.apache.org by jiny2 <gi...@git.apache.org> on 2015/11/10 06:06:53 UTC

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

GitHub user jiny2 opened a pull request:

    https://github.com/apache/incubator-hawq/pull/90

    HAWQ-141. memory accessing panic in system test

    The idea of the fix is to avoid calling gethostbyname() in multi-thread env.  The required address information are prepared before creating heart-beat thread.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jiny2/incubator-hawq HAWQ-141

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-hawq/pull/90.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #90
    
----
commit 46255cb0ee862ec88f0137154461c4e361476fc1
Author: Yi Jin <yj...@pivotal.io>
Date:   2015-11-10T05:05:34Z

    HAWQ-141. memory accessing panic in system test

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

Posted by jiny2 <gi...@git.apache.org>.
Github user jiny2 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/90#discussion_r44374445
  
    --- Diff: src/backend/resourcemanager/communication/rmcomm_QD2RM.c ---
    @@ -1263,43 +1324,118 @@ void *generateResourceRefreshHeartBeat(void *arg)
     
     		if ( sendcontent )
     		{
    -			int fd = -1;
    -			int res = connectToServerRemote(master_addr_host, rm_master_port, &fd);
    -			if ( res == FUNC_RETURN_OK )
    +			/* Connect to resource manager server. */
    +			struct sockaddr_in server_addr;
    +			int fd = socket(AF_INET, SOCK_STREAM, 0);
    +			if ( fd < 0 )
     			{
    -				RMMessageHead phead = (RMMessageHead)messagehead;
    -				RMMessageTail ptail = (RMMessageTail)messagetail;
    -				phead->Mark1       = 0;
    -				phead->Mark2       = 0;
    -				phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    -				phead->MessageSize = contbuffer.Cursor + 1;
    -
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    -				appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    -
    -				if ( sendWithRetry(fd, sendbuffer.Buffer, sendbuffer.Cursor+1, false) == FUNC_RETURN_OK) {
    -					RPCResponseRefreshResourceHeartBeatData response;
    -					/* Do not care response at all. */
    -					char recvbuf[16 + 8 + sizeof(response)];
    -					if (recvWithRetry(fd, recvbuf, sizeof(recvbuf), false) != FUNC_RETURN_OK)
    +				write_log("ERROR generateResourceRefreshHeartBeat failed to open "
    +						  "socket (errno %d)", errno);
    +				break;
    +			}
    +			memset(&server_addr, 0, sizeof(server_addr));
    +			server_addr.sin_family = AF_INET;
    +			memcpy(&(server_addr.sin_addr.s_addr),
    +				   tharg->HostAddrs[0],
    +				   tharg->HostAddrLength);
    +			server_addr.sin_port = htons(rm_master_port);
    +
    +			int sockres = 0;
    +			while(true)
    +			{
    +				sockres = connect(fd,
    +								  (struct sockaddr *)&server_addr,
    +								  sizeof(server_addr));
    +				if( sockres < 0)
    +				{
    +					if (errno == EINTR)
     					{
    -					  write_log("generateResourceRefreshHeartBeat recv error (errno %d)", errno);
    +						continue;
     					}
    -				}
    -				else
    +					else
    +					{
    +						write_log("ERROR generateResourceRefreshHeartBeat "
    +								  "failed to connect to resource manager, "
    +								  "fd %d (errno %d)", fd, errno);
    +						close(fd);
    +					}
    +					break;
    +			    }
    +				break;
    +			}
    +
    +			if ( sockres < 0 )
    +			{
    +				pg_usleep(1000000L);
    +				continue;
    +			}
    +
    +			RMMessageHead phead = (RMMessageHead)messagehead;
    +			RMMessageTail ptail = (RMMessageTail)messagetail;
    +			phead->Mark1       = 0;
    +			phead->Mark2       = 0;
    +			phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    +			phead->MessageSize = contbuffer.Cursor + 1;
    +
    +			appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    +			appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    +			appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    +
    +			if ( sendWithRetry(fd,
    +							   sendbuffer.Buffer,
    +							   sendbuffer.Cursor+1,
    +							   false) == FUNC_RETURN_OK)
    +			{
    +				RPCResponseRefreshResourceHeartBeatData response;
    +				/* Do not care response at all. */
    +				char recvbuf[sizeof(messagehead) +
    +							 sizeof(messagetail) +
    +							 sizeof(response)];
    +
    +				if ( recvWithRetry(fd,
    +							       recvbuf,
    +								   sizeof(recvbuf),
    +								   false) != FUNC_RETURN_OK)
     				{
    -				  write_log("generateResourceRefreshHeartBeat send error (errno %d)", errno);
    +					write_log("ERROR generateResourceRefreshHeartBeat recv error "
    +							  "(errno %d)", errno);
     				}
     			}
    -			closeConnectionRemote(&fd);
    +			else
    +			{
    +				write_log("ERROR generateResourceRefreshHeartBeat send error "
    +						  "(errno %d)", errno);
    +			}
    +			close(fd);
    --- End diff --
    
    The logic is to just reconnect and resend no matter currently, the message is sent with or without error.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

Posted by jiny2 <gi...@git.apache.org>.
Github user jiny2 closed the pull request at:

    https://github.com/apache/incubator-hawq/pull/90


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

Posted by jiny2 <gi...@git.apache.org>.
Github user jiny2 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/90#discussion_r44374422
  
    --- Diff: src/backend/resourcemanager/communication/rmcomm_QD2RM.c ---
    @@ -1263,43 +1324,118 @@ void *generateResourceRefreshHeartBeat(void *arg)
     
     		if ( sendcontent )
     		{
    -			int fd = -1;
    -			int res = connectToServerRemote(master_addr_host, rm_master_port, &fd);
    -			if ( res == FUNC_RETURN_OK )
    +			/* Connect to resource manager server. */
    +			struct sockaddr_in server_addr;
    +			int fd = socket(AF_INET, SOCK_STREAM, 0);
    +			if ( fd < 0 )
     			{
    -				RMMessageHead phead = (RMMessageHead)messagehead;
    -				RMMessageTail ptail = (RMMessageTail)messagetail;
    -				phead->Mark1       = 0;
    -				phead->Mark2       = 0;
    -				phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    -				phead->MessageSize = contbuffer.Cursor + 1;
    -
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    -				appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    -
    -				if ( sendWithRetry(fd, sendbuffer.Buffer, sendbuffer.Cursor+1, false) == FUNC_RETURN_OK) {
    -					RPCResponseRefreshResourceHeartBeatData response;
    -					/* Do not care response at all. */
    -					char recvbuf[16 + 8 + sizeof(response)];
    -					if (recvWithRetry(fd, recvbuf, sizeof(recvbuf), false) != FUNC_RETURN_OK)
    +				write_log("ERROR generateResourceRefreshHeartBeat failed to open "
    +						  "socket (errno %d)", errno);
    +				break;
    +			}
    +			memset(&server_addr, 0, sizeof(server_addr));
    +			server_addr.sin_family = AF_INET;
    +			memcpy(&(server_addr.sin_addr.s_addr),
    +				   tharg->HostAddrs[0],
    +				   tharg->HostAddrLength);
    +			server_addr.sin_port = htons(rm_master_port);
    +
    +			int sockres = 0;
    +			while(true)
    +			{
    +				sockres = connect(fd,
    +								  (struct sockaddr *)&server_addr,
    +								  sizeof(server_addr));
    +				if( sockres < 0)
    +				{
    +					if (errno == EINTR)
     					{
    -					  write_log("generateResourceRefreshHeartBeat recv error (errno %d)", errno);
    +						continue;
     					}
    -				}
    -				else
    +					else
    +					{
    +						write_log("ERROR generateResourceRefreshHeartBeat "
    +								  "failed to connect to resource manager, "
    +								  "fd %d (errno %d)", fd, errno);
    +						close(fd);
    +					}
    +					break;
    +			    }
    +				break;
    +			}
    +
    +			if ( sockres < 0 )
    +			{
    +				pg_usleep(1000000L);
    --- End diff --
    
    Let me check the memory free problem. Sleep 1s is for reconnecting. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

Posted by zhangh43 <gi...@git.apache.org>.
Github user zhangh43 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/90#discussion_r44373290
  
    --- Diff: src/backend/resourcemanager/communication/rmcomm_QD2RM.c ---
    @@ -234,12 +245,59 @@ void initializeQD2RMComm(void)
         /* Start resource heart-beat thread. */
         if ( rm_session_lease_heartbeat_enable )
         {
    +    	/* Resolve resource manager server address here before creating thread. */
    +    	struct hostent *rmserver = gethostbyname(master_addr_host);
    +    	if ( rmserver == NULL )
    +    	{
    +    		elog(ERROR, "failed to resolve resource manager hostname %s. herror %s",
    +    					master_addr_host,
    +						hstrerror(h_errno));
    +    	}
    +
    +    	HeartBeatThreadArg tharg = malloc(sizeof(HeartBeatThreadArgData));
    +    	tharg->HostAddrLength = rmserver->h_length;
    +    	tharg->HostAddrs      = NULL;
    +    	tharg->HostAddrSize   = 0;
    +
    +    	/* Get total and INET address count. */
    +    	int addrcnt = 0;
    +    	while( rmserver->h_addr_list[addrcnt] != NULL )
    +    	{
    +    		addrcnt++;
    +    		if ( rmserver->h_addrtype == AF_INET )
    +    		{
    +    			tharg->HostAddrSize++;
    +    		}
    +    	}
    +    	elog(DEBUG3, "Resolved resource manager host %s to %d INET addresses.",
    +    				 master_addr_host,
    +					 tharg->HostAddrSize);
    +
    +    	tharg->HostAddrs = malloc(sizeof(char *) * tharg->HostAddrSize);
    --- End diff --
    
    I think in line 1433 you also need to free (*arg)->HostAddrs.
    but also pay attention to line 276: if h_addrtype != AF_INET then tharg->HostAddrSize =0, which leads to  malloc(0) happens.  In this case, you should not free (*arg)->HostAddrs



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

Posted by zhangh43 <gi...@git.apache.org>.
Github user zhangh43 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/90#discussion_r44375986
  
    --- Diff: src/backend/resourcemanager/communication/rmcomm_QD2RM.c ---
    @@ -1263,43 +1324,118 @@ void *generateResourceRefreshHeartBeat(void *arg)
     
     		if ( sendcontent )
     		{
    -			int fd = -1;
    -			int res = connectToServerRemote(master_addr_host, rm_master_port, &fd);
    -			if ( res == FUNC_RETURN_OK )
    +			/* Connect to resource manager server. */
    +			struct sockaddr_in server_addr;
    +			int fd = socket(AF_INET, SOCK_STREAM, 0);
    +			if ( fd < 0 )
     			{
    -				RMMessageHead phead = (RMMessageHead)messagehead;
    -				RMMessageTail ptail = (RMMessageTail)messagetail;
    -				phead->Mark1       = 0;
    -				phead->Mark2       = 0;
    -				phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    -				phead->MessageSize = contbuffer.Cursor + 1;
    -
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    -				appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    -
    -				if ( sendWithRetry(fd, sendbuffer.Buffer, sendbuffer.Cursor+1, false) == FUNC_RETURN_OK) {
    -					RPCResponseRefreshResourceHeartBeatData response;
    -					/* Do not care response at all. */
    -					char recvbuf[16 + 8 + sizeof(response)];
    -					if (recvWithRetry(fd, recvbuf, sizeof(recvbuf), false) != FUNC_RETURN_OK)
    +				write_log("ERROR generateResourceRefreshHeartBeat failed to open "
    +						  "socket (errno %d)", errno);
    +				break;
    +			}
    +			memset(&server_addr, 0, sizeof(server_addr));
    +			server_addr.sin_family = AF_INET;
    +			memcpy(&(server_addr.sin_addr.s_addr),
    +				   tharg->HostAddrs[0],
    +				   tharg->HostAddrLength);
    +			server_addr.sin_port = htons(rm_master_port);
    +
    +			int sockres = 0;
    +			while(true)
    +			{
    +				sockres = connect(fd,
    +								  (struct sockaddr *)&server_addr,
    +								  sizeof(server_addr));
    +				if( sockres < 0)
    +				{
    +					if (errno == EINTR)
     					{
    -					  write_log("generateResourceRefreshHeartBeat recv error (errno %d)", errno);
    +						continue;
     					}
    -				}
    -				else
    +					else
    +					{
    +						write_log("ERROR generateResourceRefreshHeartBeat "
    +								  "failed to connect to resource manager, "
    +								  "fd %d (errno %d)", fd, errno);
    +						close(fd);
    +					}
    +					break;
    +			    }
    +				break;
    +			}
    +
    +			if ( sockres < 0 )
    +			{
    +				pg_usleep(1000000L);
    +				continue;
    +			}
    +
    +			RMMessageHead phead = (RMMessageHead)messagehead;
    +			RMMessageTail ptail = (RMMessageTail)messagetail;
    +			phead->Mark1       = 0;
    +			phead->Mark2       = 0;
    +			phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    +			phead->MessageSize = contbuffer.Cursor + 1;
    +
    +			appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    +			appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    +			appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    +
    +			if ( sendWithRetry(fd,
    +							   sendbuffer.Buffer,
    +							   sendbuffer.Cursor+1,
    +							   false) == FUNC_RETURN_OK)
    +			{
    +				RPCResponseRefreshResourceHeartBeatData response;
    +				/* Do not care response at all. */
    +				char recvbuf[sizeof(messagehead) +
    +							 sizeof(messagetail) +
    +							 sizeof(response)];
    +
    +				if ( recvWithRetry(fd,
    +							       recvbuf,
    +								   sizeof(recvbuf),
    +								   false) != FUNC_RETURN_OK)
     				{
    -				  write_log("generateResourceRefreshHeartBeat send error (errno %d)", errno);
    +					write_log("ERROR generateResourceRefreshHeartBeat recv error "
    +							  "(errno %d)", errno);
     				}
     			}
    -			closeConnectionRemote(&fd);
    +			else
    +			{
    +				write_log("ERROR generateResourceRefreshHeartBeat send error "
    +						  "(errno %d)", errno);
    +			}
    +			close(fd);
    --- End diff --
    
    got it


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

Posted by zhangh43 <gi...@git.apache.org>.
Github user zhangh43 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/90#discussion_r44373709
  
    --- Diff: src/backend/resourcemanager/communication/rmcomm_QD2RM.c ---
    @@ -1263,43 +1324,118 @@ void *generateResourceRefreshHeartBeat(void *arg)
     
     		if ( sendcontent )
     		{
    -			int fd = -1;
    -			int res = connectToServerRemote(master_addr_host, rm_master_port, &fd);
    -			if ( res == FUNC_RETURN_OK )
    +			/* Connect to resource manager server. */
    +			struct sockaddr_in server_addr;
    +			int fd = socket(AF_INET, SOCK_STREAM, 0);
    +			if ( fd < 0 )
     			{
    -				RMMessageHead phead = (RMMessageHead)messagehead;
    -				RMMessageTail ptail = (RMMessageTail)messagetail;
    -				phead->Mark1       = 0;
    -				phead->Mark2       = 0;
    -				phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    -				phead->MessageSize = contbuffer.Cursor + 1;
    -
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    -				appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    -
    -				if ( sendWithRetry(fd, sendbuffer.Buffer, sendbuffer.Cursor+1, false) == FUNC_RETURN_OK) {
    -					RPCResponseRefreshResourceHeartBeatData response;
    -					/* Do not care response at all. */
    -					char recvbuf[16 + 8 + sizeof(response)];
    -					if (recvWithRetry(fd, recvbuf, sizeof(recvbuf), false) != FUNC_RETURN_OK)
    +				write_log("ERROR generateResourceRefreshHeartBeat failed to open "
    +						  "socket (errno %d)", errno);
    +				break;
    +			}
    +			memset(&server_addr, 0, sizeof(server_addr));
    +			server_addr.sin_family = AF_INET;
    +			memcpy(&(server_addr.sin_addr.s_addr),
    +				   tharg->HostAddrs[0],
    +				   tharg->HostAddrLength);
    +			server_addr.sin_port = htons(rm_master_port);
    +
    +			int sockres = 0;
    +			while(true)
    +			{
    +				sockres = connect(fd,
    +								  (struct sockaddr *)&server_addr,
    +								  sizeof(server_addr));
    +				if( sockres < 0)
    +				{
    +					if (errno == EINTR)
     					{
    -					  write_log("generateResourceRefreshHeartBeat recv error (errno %d)", errno);
    +						continue;
     					}
    -				}
    -				else
    +					else
    +					{
    +						write_log("ERROR generateResourceRefreshHeartBeat "
    +								  "failed to connect to resource manager, "
    +								  "fd %d (errno %d)", fd, errno);
    +						close(fd);
    +					}
    +					break;
    +			    }
    +				break;
    +			}
    +
    +			if ( sockres < 0 )
    +			{
    +				pg_usleep(1000000L);
    --- End diff --
    
    logic here is sleep 1s and reconnect when connect failed?
    Is there a need to add max_retry_num?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...

Posted by zhangh43 <gi...@git.apache.org>.
Github user zhangh43 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/90#discussion_r44373653
  
    --- Diff: src/backend/resourcemanager/communication/rmcomm_QD2RM.c ---
    @@ -1263,43 +1324,118 @@ void *generateResourceRefreshHeartBeat(void *arg)
     
     		if ( sendcontent )
     		{
    -			int fd = -1;
    -			int res = connectToServerRemote(master_addr_host, rm_master_port, &fd);
    -			if ( res == FUNC_RETURN_OK )
    +			/* Connect to resource manager server. */
    +			struct sockaddr_in server_addr;
    +			int fd = socket(AF_INET, SOCK_STREAM, 0);
    +			if ( fd < 0 )
     			{
    -				RMMessageHead phead = (RMMessageHead)messagehead;
    -				RMMessageTail ptail = (RMMessageTail)messagetail;
    -				phead->Mark1       = 0;
    -				phead->Mark2       = 0;
    -				phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    -				phead->MessageSize = contbuffer.Cursor + 1;
    -
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    -				appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    -				appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    -
    -				if ( sendWithRetry(fd, sendbuffer.Buffer, sendbuffer.Cursor+1, false) == FUNC_RETURN_OK) {
    -					RPCResponseRefreshResourceHeartBeatData response;
    -					/* Do not care response at all. */
    -					char recvbuf[16 + 8 + sizeof(response)];
    -					if (recvWithRetry(fd, recvbuf, sizeof(recvbuf), false) != FUNC_RETURN_OK)
    +				write_log("ERROR generateResourceRefreshHeartBeat failed to open "
    +						  "socket (errno %d)", errno);
    +				break;
    +			}
    +			memset(&server_addr, 0, sizeof(server_addr));
    +			server_addr.sin_family = AF_INET;
    +			memcpy(&(server_addr.sin_addr.s_addr),
    +				   tharg->HostAddrs[0],
    +				   tharg->HostAddrLength);
    +			server_addr.sin_port = htons(rm_master_port);
    +
    +			int sockres = 0;
    +			while(true)
    +			{
    +				sockres = connect(fd,
    +								  (struct sockaddr *)&server_addr,
    +								  sizeof(server_addr));
    +				if( sockres < 0)
    +				{
    +					if (errno == EINTR)
     					{
    -					  write_log("generateResourceRefreshHeartBeat recv error (errno %d)", errno);
    +						continue;
     					}
    -				}
    -				else
    +					else
    +					{
    +						write_log("ERROR generateResourceRefreshHeartBeat "
    +								  "failed to connect to resource manager, "
    +								  "fd %d (errno %d)", fd, errno);
    +						close(fd);
    +					}
    +					break;
    +			    }
    +				break;
    +			}
    +
    +			if ( sockres < 0 )
    +			{
    +				pg_usleep(1000000L);
    +				continue;
    +			}
    +
    +			RMMessageHead phead = (RMMessageHead)messagehead;
    +			RMMessageTail ptail = (RMMessageTail)messagetail;
    +			phead->Mark1       = 0;
    +			phead->Mark2       = 0;
    +			phead->MessageID   = REQUEST_QD_REFRESH_RESOURCE;
    +			phead->MessageSize = contbuffer.Cursor + 1;
    +
    +			appendSelfMaintainBuffer(&sendbuffer, (char *)phead, sizeof(*phead));
    +			appendSelfMaintainBuffer(&sendbuffer, contbuffer.Buffer, contbuffer.Cursor+1);
    +			appendSelfMaintainBuffer(&sendbuffer, (char *)ptail, sizeof(*ptail));
    +
    +			if ( sendWithRetry(fd,
    +							   sendbuffer.Buffer,
    +							   sendbuffer.Cursor+1,
    +							   false) == FUNC_RETURN_OK)
    +			{
    +				RPCResponseRefreshResourceHeartBeatData response;
    +				/* Do not care response at all. */
    +				char recvbuf[sizeof(messagehead) +
    +							 sizeof(messagetail) +
    +							 sizeof(response)];
    +
    +				if ( recvWithRetry(fd,
    +							       recvbuf,
    +								   sizeof(recvbuf),
    +								   false) != FUNC_RETURN_OK)
     				{
    -				  write_log("generateResourceRefreshHeartBeat send error (errno %d)", errno);
    +					write_log("ERROR generateResourceRefreshHeartBeat recv error "
    +							  "(errno %d)", errno);
     				}
     			}
    -			closeConnectionRemote(&fd);
    +			else
    +			{
    +				write_log("ERROR generateResourceRefreshHeartBeat send error "
    +						  "(errno %d)", errno);
    +			}
    +			close(fd);
    --- End diff --
    
    you only wirte log when recv and send error, Does the error affect others?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---