hawq-dev mailing list archives

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

Mime
View raw message