From 7ec7776cea6b6c6dfbb627ea82f74d419741bc98 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 11 Aug 2021 17:34:41 +0000 Subject: [PATCH] [TD-5610] resp detailed info of invalidfqdn --- src/client/src/tscServer.c | 19 ++++++++++++++++--- src/rpc/src/rpcMain.c | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index f0ee180bbe..fde063b38f 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -502,13 +502,26 @@ static void doProcessMsgFromServer(SSchedMsg* pSchedMsg) { } rpcMsg->code = (pRes->code == TSDB_CODE_SUCCESS) ? (int32_t)pRes->numOfRows : pRes->code; if (pRes->code == TSDB_CODE_RPC_FQDN_ERROR) { + + tscAllocPayload(pCmd, TSDB_FQDN_LEN + 64); + // handle three situation + // 1. epset retry, only return last failure ep + // 2. no epset retry, like 'taos -h invalidFqdn', return invalidFqdn + // 3. other situation, not expected if (pEpSet) { - char buf[TSDB_FQDN_LEN + 64] = {0}; - tscAllocPayload(pCmd, sizeof(buf)); sprintf(tscGetErrorMsgPayload(pCmd), "%s\"%s\"", tstrerror(pRes->code),pEpSet->fqdn[(pEpSet->inUse)%(pEpSet->numOfEps)]); + } else if (pCmd->command >= TSDB_SQL_MGMT) { + SRpcEpSet tEpset; + + SRpcCorEpSet *pCorEpSet = pSql->pTscObj->tscCorMgmtEpSet; + taosCorBeginRead(&pCorEpSet->version); + tEpset = pCorEpSet->epSet; + taosCorEndRead(&pCorEpSet->version); + + sprintf(tscGetErrorMsgPayload(pCmd), "%s\"%s\"", tstrerror(pRes->code),tEpset.fqdn[(tEpset.inUse)%(tEpset.numOfEps)]); } else { sprintf(tscGetErrorMsgPayload(pCmd), "%s", tstrerror(pRes->code)); - } + } } (*pSql->fp)(pSql->param, pSql, rpcMsg->code); } diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index c93a3f929d..e958a8e5ec 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1133,8 +1133,8 @@ static void rpcNotifyClient(SRpcReqContext *pContext, SRpcMsg *pMsg) { } else { // for asynchronous API SRpcEpSet *pEpSet = NULL; - //if (pContext->epSet.inUse != pContext->oldInUse || pContext->redirect) - pEpSet = &pContext->epSet; + if (pContext->epSet.inUse != pContext->oldInUse || pContext->redirect) + pEpSet = &pContext->epSet; (*pRpc->cfp)(pMsg, pEpSet); }