From 411d30f3db8d1ddf4d6d7604b4799bfdd36f56fb Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 24 Jun 2022 11:19:16 +0800 Subject: [PATCH] handle except --- source/libs/transport/inc/transComm.h | 1 + source/libs/transport/src/transCli.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 327fe50814..bbd9ce3a78 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -125,6 +125,7 @@ typedef struct { STransMsg* pRsp; // for synchronous API tsem_t* pSem; // for synchronous API SCvtAddr cvtAddr; + bool setMaxRetry; int hThrdIdx; } STransConnCtx; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 0dd00e0dc2..beaef2758e 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -980,7 +980,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { tTrace("try to send req to next node"); pMsg->st = taosGetTimestampUs(); pCtx->retryCount += 1; - if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { + if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL && pCtx->setMaxRetry == false) { if (pCtx->retryCount < pEpSet->numOfEps * 3) { pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; if (pThrd->quit == false) { @@ -997,6 +997,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { } } } else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) { + pCtx->setMaxRetry = true; if (pResp->contLen == 0) { pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; transPrintEpSet(&pCtx->epSet); @@ -1012,8 +1013,10 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pCtx->retryCount + 1, TRANS_RETRY_COUNT_LIMIT); } if (pThrd->quit == false) { - if (pConn->status != ConnInPool) { + if (pConn->status != ConnInPool && pResp->code != TSDB_CODE_RPC_NETWORK_UNAVAIL) { addConnToPool(pThrd->pool, pConn); + } else { + transUnrefCliHandle(pConn); } STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); arg->param1 = pMsg; -- GitLab