From 2830f322d41f5901bc68ef01809ca3319d182dfa Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Wed, 20 Nov 2019 14:19:23 +0800 Subject: [PATCH] [tbase-1203] --- src/client/src/tscServer.c | 12 ++++++++++++ src/client/src/tscSql.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 436bfa327a..d96f94ecc0 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -184,6 +184,15 @@ void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) { pSql->vnode = TSC_MGMT_VNODE; #endif } + + // the pSql->res.code is the previous error(status) code. + if (pSql->thandle == NULL && pSql->retry >= pSql->maxRetry) { + if (pSql->res.code != TSDB_CODE_SUCCESS && pSql->res.code != TSDB_CODE_ACTION_IN_PROGRESS) { + *pCode = pSql->res.code; + } + + tscError("%p reach the max retry:%d, code:%d", pSql, pSql->retry, *pCode); + } } void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) { @@ -442,6 +451,9 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) { tscTrace("%p it shall be redirected!", pSql); taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user); pSql->thandle = NULL; + + // reset the retry times for a new mgmt node + pSql->retry = 0; if (pCmd->command > TSDB_SQL_MGMT) { tscProcessMgmtRedirect(pSql, pMsg->content + 1); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 6ec8f425ca..9dd9649a01 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -245,9 +245,9 @@ int taos_query_imp(STscObj* pObj, SSqlObj* pSql) { pRes->qhandle = 0; pSql->thandle = NULL; - if (pRes->code != TSDB_CODE_SUCCESS) return pRes->code; - - tscDoQuery(pSql); + if (pRes->code == TSDB_CODE_SUCCESS) { + tscDoQuery(pSql); + } tscTrace("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pObj), pObj); if (pRes->code != TSDB_CODE_SUCCESS) {