diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 700a4d9daf0985e2608f365149be99ea3e24a877..367e656f064a200ace8a051a88a554808f7dae61 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -181,6 +181,7 @@ typedef struct SRequestSendRecvBody { tsem_t rspSem; // not used now __taos_async_fn_t queryFp; __taos_async_fn_t fetchFp; + EQueryExecMode execMode; void* param; SDataBuf requestMsg; int64_t queryJob; // query job, created according to sql query DAG. diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index d923929c956ff794f0c03ce05164c7c8d68c7043..d846cb93af6a2c16fd21d2f954b8393e426aa27a 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -933,6 +933,8 @@ SRequestObj* launchQuery(uint64_t connId, const char* sql, int sqlLen, bool vali void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta) { int32_t code = 0; + pRequest->body.execMode = pQuery->execMode; + switch (pQuery->execMode) { case QUERY_EXEC_MODE_LOCAL: asyncExecLocalCmd(pRequest, pQuery); @@ -1149,7 +1151,6 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t SRequestObj* pRequest = createRequest(pTscObj->id, TDMT_MND_CONNECT); if (pRequest == NULL) { destroyTscObj(pTscObj); - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; return NULL; } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 73def5b9b188b394a9ba3e0e3816a7e0944e4653..14a431feabab2934aed0a7eee46f85dbdae2009c 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -49,7 +49,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { } // this function may be called by user or system, or by both simultaneously. void taos_cleanup(void) { - tscInfo("start to cleanup client environment"); + tscDebug("start to cleanup client environment"); if (atomic_val_compare_exchange_32(&sentinel, TSC_VAR_NOT_RELEASE, TSC_VAR_RELEASED) != TSC_VAR_NOT_RELEASE) { return; } @@ -58,7 +58,10 @@ void taos_cleanup(void) { clientReqRefPool = -1; taosCloseRef(id); - cleanupTaskQueue(); + hbMgrCleanUp(); + + catalogDestroy(); + schedulerDestroy(); fmFuncMgtDestroy(); qCleanupKeywordsTable(); @@ -67,12 +70,11 @@ void taos_cleanup(void) { clientConnRefPool = -1; taosCloseRef(id); - hbMgrCleanUp(); + rpcCleanup(); + tscDebug("rpc cleanup"); - catalogDestroy(); - schedulerDestroy(); + cleanupTaskQueue(); - rpcCleanup(); tscInfo("all local resources released"); taosCleanupCfg(); taosCloseLog(); @@ -852,27 +854,24 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { } // all data has returned to App already, no need to try again - if (pResultInfo->completed && (pRequest->body.queryJob != 0)) { - pResultInfo->numOfRows = 0; - pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows); - return; - } - - // it is a local executed query, no need to do async fetch - if (pRequest->body.queryJob == 0) { - ASSERT(pResultInfo->completed && pResultInfo->numOfRows >= 0); - if (pResultInfo->localResultFetched) { - pResultInfo->numOfRows = 0; - pResultInfo->current = 0; - pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows); + if (pResultInfo->completed) { + // it is a local executed query, no need to do async fetch + if (QUERY_EXEC_MODE_LOCAL == pRequest->body.execMode) { + ASSERT(pResultInfo->numOfRows >= 0); + if (pResultInfo->localResultFetched) { + pResultInfo->numOfRows = 0; + pResultInfo->current = 0; + } else { + pResultInfo->localResultFetched = true; + } } else { - pResultInfo->localResultFetched = true; - pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows); + pResultInfo->numOfRows = 0; } + + pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows); return; } - SSchedulerReq req = { .syncReq = false, .fetchFp = fetchCallback, diff --git a/tests/script/api/stopquery.c b/tests/script/api/stopquery.c index 92baf43d854c44d94802c803396f7dcd25bfe9a8..082d987a22461725411c6528729d3de7f8e33c7c 100644 --- a/tests/script/api/stopquery.c +++ b/tests/script/api/stopquery.c @@ -633,6 +633,7 @@ int sqConCleanupSyncQuery(bool fetch) { pthread_join(qid, NULL); pthread_join(cid, NULL); + break; } CASE_LEAVE(); } @@ -648,6 +649,7 @@ int sqConCleanupAsyncQuery(bool fetch) { pthread_join(qid, NULL); pthread_join(cid, NULL); + break; } CASE_LEAVE(); } @@ -655,7 +657,7 @@ int sqConCleanupAsyncQuery(bool fetch) { void sqRunAllCase(void) { -#if 0 +#if 1 sqStopSyncQuery(false); sqStopSyncQuery(true); sqStopAsyncQuery(false); @@ -688,16 +690,17 @@ void sqRunAllCase(void) { sqConKillAsyncQuery(true); #endif + /* sqConCleanupSyncQuery(false); sqConCleanupSyncQuery(true); sqConCleanupAsyncQuery(false); sqConCleanupAsyncQuery(true); - + */ int32_t l = 5; while (l) { printf("%d\n", l--); - sleep(1000); + sleep(1); } }