feature(rpc): add retry
This commit is contained in:
parent
c08fcc625c
commit
317adb166a
|
@ -887,18 +887,30 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
||||||
|
|
||||||
STransConnCtx* pCtx = pMsg->ctx;
|
STransConnCtx* pCtx = pMsg->ctx;
|
||||||
SEpSet* pEpSet = &pCtx->epSet;
|
SEpSet* pEpSet = &pCtx->epSet;
|
||||||
if (pTransInst->retry != NULL && pTransInst->retry(pResp->code) && pCtx->retryCount <= TRANS_RETRY_COUNT_LIMIT) {
|
|
||||||
|
tmsg_t msgType = pCtx->msgType;
|
||||||
|
if ((pTransInst->retry != NULL && (pTransInst->retry(pResp->code))) ||
|
||||||
|
((pResp->code != 0) && msgType == TDMT_MND_CONNECT)) {
|
||||||
pCtx->retryCount += 1;
|
pCtx->retryCount += 1;
|
||||||
if (pResp->contLen == 0) {
|
pMsg->st = taosGetTimestampUs();
|
||||||
pEpSet->inUse = (pEpSet->inUse++) % pEpSet->numOfEps;
|
if (msgType == TDMT_MND_CONNECT) {
|
||||||
} else {
|
if (pCtx->retryCount < pEpSet->numOfEps) {
|
||||||
SMEpSet emsg = {0};
|
pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps;
|
||||||
tDeserializeSMEpSet(pResp->pCont, pResp->contLen, &emsg);
|
cliHandleReq(pMsg, pThrd);
|
||||||
pCtx->epSet = emsg.epSet;
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) {
|
||||||
|
if (pResp->contLen == 0) {
|
||||||
|
pEpSet->inUse = (pEpSet->inUse++) % pEpSet->numOfEps;
|
||||||
|
} else {
|
||||||
|
SMEpSet emsg = {0};
|
||||||
|
tDeserializeSMEpSet(pResp->pCont, pResp->contLen, &emsg);
|
||||||
|
pCtx->epSet = emsg.epSet;
|
||||||
|
}
|
||||||
|
// release pConn
|
||||||
|
cliHandleReq(pMsg, pThrd);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
// release pConn
|
|
||||||
cliHandleReq(pMsg, pThrd);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCtx->pSem != NULL) {
|
if (pCtx->pSem != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue