feat(rpc): move the check msgType to client

This commit is contained in:
Alex Duan 2022-12-21 11:48:24 +08:00
parent 37ea86f8ed
commit 15160544c5
3 changed files with 26 additions and 10 deletions

View File

@ -66,6 +66,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) //
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) //
#define TSDB_CODE_RPC_VGROUP_NOT_CONNECTED TAOS_DEF_ERROR_CODE(0, 0x0020) // "Vgroup could not be connected"
#define TSDB_CODE_RPC_VGROUP_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0021) //
//common & util
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //

View File

@ -1424,6 +1424,26 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
memcpy((void*)tEpSet, (void*)pEpSet, sizeof(SEpSet));
}
switch (pMsg->msg.msgType) {
case TDMT_VND_BATCH_META:
case TDMT_VND_SUBMIT:
case TDMT_SCH_QUERY:
case TDMT_SCH_MERGE_QUERY:
// uniform to one error code: TSDB_CODE_RPC_VGROUP_NOT_CONNECTED
if (pMsg->code == TSDB_CODE_RPC_VGROUP_BROKEN_LINK) {
pMsg->code = TSDB_CODE_RPC_VGROUP_NOT_CONNECTED;
}
break;
default:
// restore origin code
if (pMsg->code == TSDB_CODE_RPC_VGROUP_NOT_CONNECTED) {
pMsg->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
} else if (pMsg->code == TSDB_CODE_RPC_VGROUP_BROKEN_LINK) {
pMsg->code = TSDB_CODE_RPC_BROKEN_LINK;
}
break;
}
AsyncArg* arg = taosMemoryCalloc(1, sizeof(AsyncArg));
arg->msg = *pMsg;
arg->pEpset = tEpSet;

View File

@ -1671,16 +1671,11 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
}
// check whole vnodes is offline on this vgroup
if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || pResp->code == TSDB_CODE_RPC_BROKEN_LINK) {
if (pCtx->epsetRetryCnt >= pCtx->epSet.numOfEps || pCtx->retryStep > 0) {
switch (pMsg->msg.msgType) {
case TDMT_VND_BATCH_META:
case TDMT_VND_SUBMIT:
case TDMT_SCH_QUERY:
case TDMT_SCH_MERGE_QUERY:
pResp->code = TSDB_CODE_RPC_VGROUP_NOT_CONNECTED;
break;
}
if (pCtx->epsetRetryCnt >= pCtx->epSet.numOfEps || pCtx->retryStep > 0) {
if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
pResp->code = TSDB_CODE_RPC_VGROUP_NOT_CONNECTED;
} else if (pResp->code == TSDB_CODE_RPC_BROKEN_LINK) {
pResp->code = TSDB_CODE_RPC_VGROUP_BROKEN_LINK;
}
}