提交 ad051d4e 编写于 作者: D dapan1121

fix: fix stop query issue

上级 346c8640
......@@ -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.
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册