From 33012d3d20ac87e344e52e9ea7016861348593c7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 17 Nov 2020 03:36:52 +0000 Subject: [PATCH] TD-2051 --- src/sync/src/syncMain.c | 13 ++++++++++++- src/util/src/tsocket.c | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index 302f08bdb9..6ff04aad64 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -179,6 +179,13 @@ int64_t syncStart(const SSyncInfo *pInfo) { for (int32_t i = 0; i < pCfg->replica; ++i) { const SNodeInfo *pNodeInfo = pCfg->nodeInfo + i; pNode->peerInfo[i] = syncAddPeer(pNode, pNodeInfo); + if (pNode->peerInfo[i] == NULL) { + sError("vgId:%d, node:%d fqdn:%s port:%u is not configured, stop taosd", pNode->vgId, pNodeInfo->nodeId, pNodeInfo->nodeFqdn, + pNodeInfo->nodePort); + syncStop(pNode->rid); + exit(1); + } + if ((strcmp(pNodeInfo->nodeFqdn, tsNodeFqdn) == 0) && (pNodeInfo->nodePort == tsSyncPort)) { pNode->selfIndex = i; } @@ -476,7 +483,11 @@ static void syncRemovePeer(SSyncPeer *pPeer) { static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo) { uint32_t ip = taosGetIpFromFqdn(pInfo->nodeFqdn); - if (ip == -1) return NULL; + if (ip == 0xFFFFFFFF) { + sError("failed to add peer, can resolve fqdn:%s since %s", pInfo->nodeFqdn, strerror(errno)); + terrno = TSDB_CODE_RPC_FQDN_ERROR; + return NULL; + } SSyncPeer *pPeer = calloc(1, sizeof(SSyncPeer)); if (pPeer == NULL) return NULL; diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index 11932ac03a..1be79b7bbd 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -58,13 +58,13 @@ uint32_t taosGetIpFromFqdn(const char *fqdn) { } else { #ifdef EAI_SYSTEM if (ret == EAI_SYSTEM) { - uError("failed to get the ip address, fqdn:%s, code:%d, reason:%s", fqdn, ret, strerror(errno)); + uError("failed to get the ip address, fqdn:%s, since:%s", fqdn, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); } else { - uError("failed to get the ip address, fqdn:%s, code:%d, reason:%s", fqdn, ret, gai_strerror(ret)); + uError("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret)); } #else - uError("failed to get the ip address, fqdn:%s, code:%d, reason:%s", fqdn, ret, gai_strerror(ret)); + uError("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret)); #endif return 0xFFFFFFFF; } -- GitLab