未验证 提交 e947e6a5 编写于 作者: dengyihao's avatar dengyihao 提交者: GitHub

Merge pull request #14193 from taosdata/feat/rpcRetry

fix: handle rpc retry except
...@@ -125,6 +125,7 @@ typedef struct { ...@@ -125,6 +125,7 @@ typedef struct {
STransMsg* pRsp; // for synchronous API STransMsg* pRsp; // for synchronous API
tsem_t* pSem; // for synchronous API tsem_t* pSem; // for synchronous API
SCvtAddr cvtAddr; SCvtAddr cvtAddr;
bool setMaxRetry;
int hThrdIdx; int hThrdIdx;
} STransConnCtx; } STransConnCtx;
......
...@@ -980,7 +980,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { ...@@ -980,7 +980,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
tTrace("try to send req to next node"); tTrace("try to send req to next node");
pMsg->st = taosGetTimestampUs(); pMsg->st = taosGetTimestampUs();
pCtx->retryCount += 1; 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) { if (pCtx->retryCount < pEpSet->numOfEps * 3) {
pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps;
if (pThrd->quit == false) { if (pThrd->quit == false) {
...@@ -997,6 +997,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { ...@@ -997,6 +997,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
} }
} }
} else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) { } else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) {
pCtx->setMaxRetry = true;
if (pResp->contLen == 0) { if (pResp->contLen == 0) {
pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps;
transPrintEpSet(&pCtx->epSet); transPrintEpSet(&pCtx->epSet);
...@@ -1012,8 +1013,10 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { ...@@ -1012,8 +1013,10 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
pCtx->retryCount + 1, TRANS_RETRY_COUNT_LIMIT); pCtx->retryCount + 1, TRANS_RETRY_COUNT_LIMIT);
} }
if (pThrd->quit == false) { if (pThrd->quit == false) {
if (pConn->status != ConnInPool) { if (pResp->code != TSDB_CODE_RPC_NETWORK_UNAVAIL) {
addConnToPool(pThrd->pool, pConn); if (pConn->status != ConnInPool) addConnToPool(pThrd->pool, pConn);
} else {
transUnrefCliHandle(pConn);
} }
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
arg->param1 = pMsg; arg->param1 = pMsg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册