From 9333120d422f23d2fc597b65b050c276f22f1fb6 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 10 Jun 2022 17:53:13 +0800 Subject: [PATCH] feat: add async logic for schemaless --- source/client/src/clientMain.c | 5 ++++- source/client/src/clientSml.c | 13 ++++++------- source/dnode/vnode/src/meta/metaQuery.c | 4 ++++ source/dnode/vnode/src/vnd/vnodeSvr.c | 2 ++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 5e442c4bf1..97275c0375 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -199,7 +199,10 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) { taos_query_a(pTscObj, sql, syncQueryFn, param); tsem_wait(¶m->sem); - return param->pRequest; + TAOS_RES *request = param->pRequest; + tsem_destroy(¶m->sem); + taosMemoryFree(param); + return request; #else size_t sqlLen = strlen(sql); if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index bf60d25976..d63c93bd32 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -2261,7 +2261,7 @@ static int smlProcess(SSmlHandle *info, char* lines[], int numLines) { code = smlParseLine(info, lines, numLines); if (code != 0) { uError("SML:0x%"PRIx64" smlParseLine error : %s", info->id, tstrerror(code)); - goto cleanup; + return code; } info->cost.lineNum = numLines; @@ -2277,20 +2277,16 @@ static int smlProcess(SSmlHandle *info, char* lines[], int numLines) { if (code != 0) { uError("SML:0x%"PRIx64" smlModifyDBSchemas error : %s", info->id, tstrerror(code)); - goto cleanup; + return code; } info->cost.insertBindTime = taosGetTimestampUs(); code = smlInsertData(info); if (code != 0) { uError("SML:0x%"PRIx64" smlInsertData error : %s", info->id, tstrerror(code)); - goto cleanup; + return code; } - info->cost.endTime = taosGetTimestampUs(); -cleanup: - info->cost.code = code; - smlPrintStatisticInfo(info); return code; } @@ -2329,6 +2325,9 @@ static void smlInsertCallback(void* param, void* res, int32_t code) { printf("SML:0x%" PRIx64 " insert finished, code: %d, total: %d\n", info->id, code, info->affectedRows); Params *pParam = info->params; bool isLast = info->isLast; + info->cost.endTime = taosGetTimestampUs(); + info->cost.code = code; + smlPrintStatisticInfo(info); smlDestroyInfo(info); if(isLast){ diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 063a78b0c6..ebf5098a05 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -86,11 +86,15 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) { int nData = 0; tb_uid_t uid = 0; + metaRLock(pMeta); + if (tdbTbGet(pMeta->pNameIdx, name, strlen(name) + 1, &pData, &nData) == 0) { uid = *(tb_uid_t *)pData; tdbFree(pData); } + metaULock(pMeta); + return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 1524d8fe6f..2f72a78c38 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -787,7 +787,9 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq msgIter.suid = 0; } +#ifdef TD_DEBUG_PRINT_ROW vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid"); +#endif tDecoderClear(&decoder); } else { submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN); -- GitLab