diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index af4c80eec1ce5c5b274a02e53734c91ef7da7392..8d8f3a686387d2ac510cf05c294c7aa46e479c49 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -511,6 +511,19 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { } bool shouldFree = tscShouldBeFreed(pSql); + if (rpcMsg->code == TSDB_CODE_TSC_INVALID_SCHEMA_VERSION) { + pSql->res.code = rpcMsg->code; + tscWarn("0x%" PRIx64 " it shall renew table meta, code:%s, retry:%d", pSql->self, tstrerror(rpcMsg->code), pSql->retry); + + ++pSql->retry; + if (pSql->retry > pSql->maxRetry) { + tscError("0x%" PRIx64 " max retry %d reached, give up", pSql->self, pSql->maxRetry); + } else { + pSql->retryReason = rpcMsg->code; + rpcMsg->code = tscRenewTableMeta(pSql); + } + } + if (rpcMsg->code != TSDB_CODE_TSC_ACTION_IN_PROGRESS) { if (rpcMsg->code != TSDB_CODE_SUCCESS) { pRes->code = rpcMsg->code; @@ -2820,6 +2833,12 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) { tlv = (STLV*) ((char*)tlv + sizeof(STLV) + ntohl(tlv->len)); } } + + STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; + if (pTableMeta->sversion < pSql->res.sVersion || pTableMeta->tversion < pSql->res.tVersion) { + return TSDB_CODE_TSC_INVALID_SCHEMA_VERSION; + } + return 0; } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index ce9791523c72848ccb960a057ea8a7d2cd3dc147..691eea9033345ed4cb674a391fcfee5bc4b5391c 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1713,21 +1713,6 @@ void tscFreeSqlObj(SSqlObj* pSql) { tscFreeMetaSqlObj(&pSql->svgroupRid); SSqlCmd* pCmd = &pSql->cmd; - bool clearCachedMeta = false; - SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); - if (pQueryInfo != NULL) { - STableMeta* pTableMeta = NULL; - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - if (pTableMetaInfo != NULL) { - pTableMeta = pTableMetaInfo->pTableMeta; - } - if (pTableMeta != NULL) { - if (pTableMeta->sversion < pSql->res.sVersion || pTableMeta->tversion < pSql->res.tVersion) { - clearCachedMeta = true; - } - } - } - int32_t cmd = pCmd->command; if (cmd < TSDB_SQL_INSERT || cmd == TSDB_SQL_RETRIEVE_GLOBALMERGE || cmd == TSDB_SQL_RETRIEVE_EMPTY_RESULT || cmd == TSDB_SQL_TABLE_JOIN_RETRIEVE) { @@ -1746,7 +1731,7 @@ void tscFreeSqlObj(SSqlObj* pSql) { pSql->self = 0; tscFreeSqlResult(pSql); - tscResetSqlCmd(pCmd, clearCachedMeta, pSql->self); + tscResetSqlCmd(pCmd, false, pSql->self); tfree(pCmd->payload); pCmd->allocSize = 0; diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index fb70badb862943a0259b2dc94bf52b0a452bd714..0eb2479447bc6ae65a0eef4e41aba54ea6f9b518 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -115,6 +115,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid line protocol type") #define TSDB_CODE_TSC_INVALID_PRECISION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0226) //"Invalid timestamp precision type") #define TSDB_CODE_TSC_RES_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0227) //"Result set too large to be output") +#define TSDB_CODE_TSC_INVALID_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0228) //"invalid table schema version") // mnode #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed"