diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index f2570fb22994e80e542ef3a6d2350a4aea30c6fd..21980289d6ed12aea4e990813e44f1f7bb30713e 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -163,11 +163,13 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { tscGetQueryInfoDetailSafely(&pSql->cmd, 0, &pQueryInfo); pQueryInfo->command = TSDB_SQL_HB; + pSql->cmd.command = TSDB_SQL_HB; if (TSDB_CODE_SUCCESS != tscAllocPayload(&(pSql->cmd), TSDB_DEFAULT_PAYLOAD_SIZE)) { tfree(pSql); return; } + pSql->cmd.command = TSDB_SQL_HB; pSql->param = pObj; pSql->pTscObj = pObj; pSql->signature = pSql; diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 6713f84f9922ed81763562ff1f48ad5b0a74c551..484c9e344eb0ac377605b9700b72c3a948c83159 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -67,7 +67,6 @@ int32_t tscInitRpc(const char *user, const char *secret) { rpcInit.label = "TSC-vnode"; rpcInit.numOfThreads = tscNumOfThreads; rpcInit.cfp = tscProcessMsgFromServer; - rpcInit.ufp = tscUpdateIpSet; rpcInit.sessions = tsMaxVnodeConnections; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.user = (char*)user; @@ -96,6 +95,7 @@ int32_t tscInitRpc(const char *user, const char *secret) { rpcInit.label = "TSC-mgmt"; rpcInit.numOfThreads = 1; rpcInit.cfp = tscProcessMsgFromServer; + rpcInit.ufp = tscUpdateIpSet; rpcInit.sessions = tsMaxMgmtConnections; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = 2000; diff --git a/src/dnode/src/dnodeMClient.c b/src/dnode/src/dnodeMClient.c index ee805a2a0c1aa53a90a7685ba58f798843a2ae67..151d44922d0e0de437ae8edcaecf9302646192bc 100644 --- a/src/dnode/src/dnodeMClient.c +++ b/src/dnode/src/dnodeMClient.c @@ -59,6 +59,19 @@ void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) { tsMnodeIpSet = *pIpSet; } +void dnodeGetMnodeIpSet(void *ipSetRaw, bool usePublicIp) { + SRpcIpSet *ipSet = ipSetRaw; + ipSet->numOfIps = tsMnodeInfos.nodeNum; + ipSet->inUse = tsMnodeInfos.inUse; + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; ++i) { + if (usePublicIp) { + ipSet->ip[i] = tsMnodeInfos.nodeInfos[i].nodeIp; + } else { + ipSet->ip[i] = tsMnodeInfos.nodeInfos[i].nodeIp; + } + } +} + int32_t dnodeInitMClient() { dnodeReadDnodeCfg(); tsRebootTime = taosGetTimestampSec(); @@ -138,7 +151,9 @@ static void dnodeProcessRspFromMnode(SRpcMsg *pMsg) { if (tsDnodeProcessMgmtRspFp[pMsg->msgType]) { (*tsDnodeProcessMgmtRspFp[pMsg->msgType])(pMsg); } else { - dError("%s is not processed in mnode rpc client", taosMsg[pMsg->msgType]); + dError("%s is not processed in dnode mclient", taosMsg[pMsg->msgType]); + SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = pMsg->handle}; + rpcSendResponse(&rpcRsp); } rpcFreeCont(pMsg->pCont); diff --git a/src/dnode/src/dnodeMnode.c b/src/dnode/src/dnodeMnode.c index 9672a34a9f5cc10e3dee30ce7121a62b7fe7e1e7..ac477c4de103cb9d5c59ffcce5b51612f7948bb2 100644 --- a/src/dnode/src/dnodeMnode.c +++ b/src/dnode/src/dnodeMnode.c @@ -88,7 +88,7 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) { if (dnodeProcessMgmtMsgFp[pMsg->msgType]) { (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg); } else { - dError("%s is not processed in mserver", taosMsg[pMsg->msgType]); + dError("%s is not processed in dnode mserver", taosMsg[pMsg->msgType]); rspMsg.code = TSDB_CODE_MSG_NOT_PROCESSED; rpcSendResponse(&rspMsg); rpcFreeCont(pMsg->pCont); diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 618cf79b1496f5be3001304ae4cc2f9fdc49169e..6fbfa7ffa922eab8fa1911865e041aee8c957b9b 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -41,8 +41,9 @@ void *dnodeAllocateRqueue(void *pVnode); void dnodeFreeRqueue(void *rqueue); void dnodeSendRpcWriteRsp(void *pVnode, void *param, int32_t code); -bool dnodeIsFirstDeploy(); +bool dnodeIsFirstDeploy(); uint32_t dnodeGetMnodeMasteIp(); +void dnodeGetMnodeIpSet(void *ipSet, bool usePublicIp); void * dnodeGetMnodeInfos(); int32_t dnodeGetDnodeId(); diff --git a/src/mnode/src/mgmtDClient.c b/src/mnode/src/mgmtDClient.c index f547128f0087d593fdb6c72e2e1a11e5399f7568..759d400eb82595a93041c7d8fc2228fa461f92aa 100644 --- a/src/mnode/src/mgmtDClient.c +++ b/src/mnode/src/mgmtDClient.c @@ -79,7 +79,9 @@ static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg) { if (mgmtProcessDnodeRspFp[rpcMsg->msgType]) { (*mgmtProcessDnodeRspFp[rpcMsg->msgType])(rpcMsg); } else { - mError("%s is not processed in dclient", taosMsg[rpcMsg->msgType]); + mError("%s is not processed in mgmt dclient", taosMsg[rpcMsg->msgType]); + SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = rpcMsg->handle}; + rpcSendResponse(&rpcRsp); } rpcFreeCont(rpcMsg->pCont); diff --git a/src/mnode/src/mgmtDServer.c b/src/mnode/src/mgmtDServer.c index b551c0eae52d3a3694ba0d2c09e432f13dab1155..9f65cd5d4ab0b25341f08edda8be04109319165e 100644 --- a/src/mnode/src/mgmtDServer.c +++ b/src/mnode/src/mgmtDServer.c @@ -108,8 +108,12 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { bool usePublicIp = false; SRpcIpSet ipSet = {0}; - mgmtGetMnodeIpSet(&ipSet, usePublicIp); - mTrace("conn from dnode ip:%s redirect msg", taosIpStr(connInfo.clientIp)); + ipSet.port = tsMnodeDnodePort; + dnodeGetMnodeIpSet(&ipSet, usePublicIp); + mTrace("conn from dnode ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); + for (int32_t i = 0; i < ipSet.numOfIps; ++i) { + mTrace("index:%d ip:%s", i, taosIpStr(ipSet.ip[i])); + } rpcSendRedirectRsp(rpcMsg->handle, &ipSet); return; } @@ -119,7 +123,8 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { memcpy(pMsg, rpcMsg, sizeof(SRpcMsg)); mgmtAddToDServerQueue(pMsg); } else { - mError("%s is not processed in dserver", taosMsg[rpcMsg->msgType]); + mError("%s is not processed in mgmt dserver", taosMsg[rpcMsg->msgType]); + mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_MSG_NOT_PROCESSED); rpcFreeCont(rpcMsg->pCont); } } diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 752f33db13b4a13cbfc0752b54f43c26bd1d45cf..927bbe4ed1d1055ca8da8ee1422e09b253403631 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -151,8 +151,13 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { bool usePublicIp = (connInfo.serverIp == tsPublicIpInt); SRpcIpSet ipSet = {0}; - mgmtGetMnodeIpSet(&ipSet, usePublicIp); - mTrace("conn from ip:%s user:%s redirect msg", taosIpStr(connInfo.clientIp), connInfo.user); + ipSet.port = tsMnodeShellPort; + dnodeGetMnodeIpSet(&ipSet, usePublicIp); + mTrace("conn from shell ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); + for (int32_t i = 0; i < ipSet.numOfIps; ++i) { + mTrace("index:%d ip:%s", i, taosIpStr(ipSet.ip[i])); + } + rpcSendRedirectRsp(rpcMsg->handle, &ipSet); return; } @@ -429,9 +434,9 @@ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) { connect_over: rpcRsp.code = code; if (code != TSDB_CODE_SUCCESS) { - mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); + mLError("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code)); } else { - mLPrint("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); + mLPrint("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code)); rpcRsp.pCont = pConnectRsp; rpcRsp.contLen = sizeof(SCMConnectRsp); } @@ -488,7 +493,7 @@ static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg) { } static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg) { - mError("%s is not processed in shell", taosMsg[rpcMsg->msgType]); + mError("%s is not processed in mnode shell", taosMsg[rpcMsg->msgType]); SRpcMsg rpcRsp = { .msgType = 0, .pCont = 0, diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index b1aa7c6382c9305ee34c92ebc901beb1e974ee9b..41ba3c425ad9cf8e1e587ee6cdeef75c3f5514dc 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -93,7 +93,7 @@ echo "privateIp $NODE_IP" >> $TAOS_CFG echo "dDebugFlag 199" >> $TAOS_CFG echo "mDebugFlag 199" >> $TAOS_CFG echo "sdbDebugFlag 199" >> $TAOS_CFG -echo "rpcDebugFlag 131" >> $TAOS_CFG +echo "rpcDebugFlag 135" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG echo "cDebugFlag 135" >> $TAOS_CFG echo "httpDebugFlag 131" >> $TAOS_CFG diff --git a/tests/script/unique/mnode/mgmt33.sim b/tests/script/unique/mnode/mgmt33.sim index 629adad029a11efb0e35ca3e5178d3877538962e..b2235ca6dc93250700b32e2cbf8c7f146827199b 100644 --- a/tests/script/unique/mnode/mgmt33.sim +++ b/tests/script/unique/mnode/mgmt33.sim @@ -116,7 +116,7 @@ sleep 8000 sql show mnodes $dnode1Role = $data3_1 -$dnode2Role = $data3_2 +$dnode2Role = $data3_4 $dnode3Role = $data3_3 print 192.168.0.1 ==> $dnode1Role print 192.168.0.2 ==> $dnode2Role @@ -138,13 +138,13 @@ sleep 10000 sql show mnodes $dnode1Role = $data3_1 -$dnode2Role = $data3_2 +$dnode2Role = $data3_4 $dnode3Role = $data3_3 print 192.168.0.1 ==> $dnode1Role print 192.168.0.2 ==> $dnode2Role print 192.168.0.3 ==> $dnode3Role -if $dnode1Role != undecided then +if $dnode1Role != offline then return -1 endi #if $dnode2Role != master then diff --git a/tests/script/unique/mnode/mgmt34.sim b/tests/script/unique/mnode/mgmt34.sim index c811728debe1067c0cc4e88d479866797c44421a..1c12b2ee392b6c02e520c06a71e355e7bc311025 100644 --- a/tests/script/unique/mnode/mgmt34.sim +++ b/tests/script/unique/mnode/mgmt34.sim @@ -183,7 +183,7 @@ endi print ============== step7 system sh/exec_up.sh -n dnode1 -s stop -sleep 10000 +sleep 4000 sql show mnodes $dnode1Role = $data3_1 @@ -195,7 +195,7 @@ print 192.168.0.2 ==> $dnode2Role print 192.168.0.3 ==> $dnode3Role print 192.168.0.4 ==> $dnode4Role -if $dnode1Role != undecided then +if $dnode1Role != offline then return -1 endi @@ -205,7 +205,7 @@ sleep 8000 sql show mnodes $dnode1Role = $data3_1 -$dnode2Role = $data3_2 +$dnode2Role = $data3_5 $dnode3Role = $data3_3 $dnode4Role = $data3_4 print 192.168.0.1 ==> $dnode1Role