From 519cd6aee706726246c6f2cda8c560db92368aa1 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 8 Jun 2020 09:44:25 +0800 Subject: [PATCH] td-449: set parse finsish flag in select statement --- src/client/src/tscAsync.c | 6 ++++-- src/client/src/tscSQLParser.c | 3 ++- src/client/src/tscStream.c | 19 ++++++------------- tests/script/general/stream/new_stream.sim | 22 +++++++++++----------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 3723c0cf65..a9c170f197 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -517,8 +517,10 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { if (pSql->pStream) { tscTrace("%p stream:%p meta is updated, start new query, command:%d", pSql, pSql->pStream, pSql->cmd.command); - tsParseSql(pSql, false); - sem_post(&pSql->rspSem); + if (!pSql->cmd.parseFinished) { + tsParseSql(pSql, false); + sem_post(&pSql->rspSem); + } return; } else { tscTrace("%p get tableMeta successfully", pSql); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 68980bef98..1584b52e9f 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -515,8 +515,9 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { if (ret != 0) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - } + } + pCmd->parseFinished = 1; return TSDB_CODE_SUCCESS; // do not build query message here } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index f13e99d7b3..c4413f8541 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -78,30 +78,23 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) { int code = tscGetTableMeta(pSql, pTableMetaInfo); pSql->res.code = code; - if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) return; - if (code == 0 && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { code = tscGetSTableVgroupInfo(pSql, 0); pSql->res.code = code; - - if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) return; } - tscTansformSQLFuncForSTableQuery(pQueryInfo); - // failed to get meter/metric meta, retry in 10sec. if (code != TSDB_CODE_SUCCESS) { int64_t retryDelayTime = tscGetRetryDelayTime(pStream->slidingTime, pStream->precision); tscError("%p stream:%p,get metermeta failed, retry in %" PRId64 "ms", pStream->pSql, pStream, retryDelayTime); - tscSetRetryTimer(pStream, pSql, retryDelayTime); - return; - } - - tscTrace("%p stream:%p start stream query on:%s", pSql, pStream, pTableMetaInfo->name); - tscDoQuery(pStream->pSql); - tscIncStreamExecutionCount(pStream); + } else { + tscTansformSQLFuncForSTableQuery(pQueryInfo); + tscTrace("%p stream:%p start stream query on:%s", pSql, pStream, pTableMetaInfo->name); + tscDoQuery(pStream->pSql); + tscIncStreamExecutionCount(pStream); + } } static void tscProcessStreamTimer(void *handle, void *tmrId) { diff --git a/tests/script/general/stream/new_stream.sim b/tests/script/general/stream/new_stream.sim index 8aa0a89870..abc06faaef 100644 --- a/tests/script/general/stream/new_stream.sim +++ b/tests/script/general/stream/new_stream.sim @@ -1,12 +1,12 @@ -system sh/stop_dnodes.sh +#system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10 -system sh/exec.sh -n dnode1 -s start +#system sh/deploy.sh -n dnode1 -i 1 +#system sh/cfg.sh -n dnode1 -c walLevel -v 0 +#system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10 +#system sh/exec.sh -n dnode1 -s start -sleep 3000 +#sleep 3000 sql connect print ======================== dnode1 start @@ -56,14 +56,14 @@ print $data00 $data01 $data02 $data03 sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(10s) print =============== step3 -print sleep 22 seconds -sleep 22000 +print sleep 120 seconds +sleep 120000 print =============== step4 sql select * from $st print $st ==> $rows1 $data00 $data01 $data02 $data03 -if $data13 >= 51 then +if $data03 >= 51 then return -1 endi @@ -90,8 +90,8 @@ while $i < $tbNum endw print =============== step6 -print sleep 22 seconds -sleep 22000 +print sleep 120 seconds +sleep 120000 print =============== step7 -- GitLab