hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhangh43 <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...
Date Tue, 10 Nov 2015 06:26:27 GMT
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.
---

Mime
View raw message