From 139dabf1515dabcf760868a7152b80548025f06e Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Thu, 3 Sep 2020 18:32:06 +0800 Subject: [PATCH] td-804: fix infinite SQL parse retry --- src/client/inc/tsclient.h | 1 + src/client/src/tscAsync.c | 1 + src/client/src/tscParseInsert.c | 12 ++++-------- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 78544b9b99..5f4a46ddad 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -348,6 +348,7 @@ typedef struct SSqlObj { void * pStream; void * pSubscription; char * sqlstr; + char parseRetry; char retry; char maxRetry; SRpcEpSet epSet; diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 650f101645..d07089539a 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -43,6 +43,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const pSql->signature = pSql; pSql->param = param; pSql->pTscObj = pObj; + pSql->parseRetry= 0; pSql->maxRetry = TSDB_MAX_REPLICA; pSql->fp = fp; pSql->fetchFp = fp; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 7f8fd7f4fe..09eb8f167e 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1335,13 +1335,13 @@ int tsParseSql(SSqlObj *pSql, bool initial) { // make a backup as tsParseInsertSql may modify the string char* sqlstr = strdup(pSql->sqlstr); ret = tsParseInsertSql(pSql); - if (sqlstr == NULL || pSql->retry >= 1 || ret != TSDB_CODE_TSC_INVALID_SQL) { + if (sqlstr == NULL || pSql->parseRetry >= 1 || ret != TSDB_CODE_TSC_INVALID_SQL) { free(sqlstr); } else { tscResetSqlCmdObj(pCmd, true); free(pSql->sqlstr); pSql->sqlstr = sqlstr; - pSql->retry++; + pSql->parseRetry++; if ((ret = tsInsertInitialCheck(pSql)) == TSDB_CODE_SUCCESS) { ret = tsParseInsertSql(pSql); } @@ -1349,18 +1349,14 @@ int tsParseSql(SSqlObj *pSql, bool initial) { } else { SSqlInfo SQLInfo = qSQLParse(pSql->sqlstr); ret = tscToSQLCmd(pSql, &SQLInfo); - if (ret == TSDB_CODE_TSC_INVALID_SQL && pSql->retry == 0 && SQLInfo.type == TSDB_SQL_NULL) { + if (ret == TSDB_CODE_TSC_INVALID_SQL && pSql->parseRetry == 0 && SQLInfo.type == TSDB_SQL_NULL) { tscResetSqlCmdObj(pCmd, true); - pSql->retry++; + pSql->parseRetry++; ret = tscToSQLCmd(pSql, &SQLInfo); } SQLInfoDestroy(&SQLInfo); } - if (ret == TSDB_CODE_SUCCESS) { - pSql->retry = 0; - } - /* * the pRes->code may be modified or released by another thread in tscTableMetaCallBack function, * so do NOT use pRes->code to determine if the getTableMeta function -- GitLab