From a8f54e97af412087ff6eb1d5b9445fc34cfaa16b Mon Sep 17 00:00:00 2001 From: xywang Date: Fri, 10 Jun 2022 09:40:07 +0800 Subject: [PATCH] fix: super table info not removed after dropped by another client --- src/client/src/tscAsync.c | 15 ++++++++++++++- src/client/src/tscSQLParser.c | 11 ++++++++--- src/client/src/tscUtil.c | 8 -------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 4ac23241fa..911da05b43 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -338,6 +338,10 @@ void tscAsyncResultOnError(SSqlObj* pSql) { int tscSendMsgToServer(SSqlObj *pSql); void tscClearTableMeta(SSqlObj *pSql); +static void freeElem(void* p) { + tfree(*(char**)p); +} + void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)param); if (pSql == NULL) return; @@ -357,13 +361,22 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { tscAllocPayload(&pSql->cmd, (int)sz + 1); memcpy(tscGetErrorMsgPayload(&pSql->cmd), tscGetErrorMsgPayload(&sub->cmd), sz); } else if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { - if (sub->cmd.command == TSDB_SQL_MULTI_META) { + if (sub->cmd.command == TSDB_SQL_MULTI_META && pSql->cmd.hashedTableNames) { tscClearTableMeta(pSql); + taosArrayDestroyEx(&pSql->cmd.hashedTableNames, freeElem); + pSql->cmd.hashedTableNames = NULL; } } goto _error; } + if (sub->cmd.command == TSDB_SQL_MULTI_META) { + if (pSql->cmd.hashedTableNames) { + taosArrayDestroyEx(&pSql->cmd.hashedTableNames, freeElem); + pSql->cmd.hashedTableNames = NULL; + } + } + tscDebug("0x%"PRIx64" get %s successfully", pSql->self, msg); if (pSql->pStream == NULL) { SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 4bac9f50b6..d301a4da1a 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -9434,7 +9434,6 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); pCmd->pTableMetaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - pCmd->hashedTableNames = taosArrayInit(4, POINTER_BYTES); tableNameList = taosArrayInit(4, sizeof(SName)); size_t size = taosArrayGetSize(pInfo->list); @@ -9503,8 +9502,14 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { taosArrayPush(pVgroupList, &t); tscDebug("0x%"PRIx64" failed to retrieve stable %s vgroup id list in cache, try fetch from mnode", pSql->self, name); - char* tb = strdup(name); - taosArrayPush(pCmd->hashedTableNames, &tb); + if (pCmd->hashedTableNames == NULL) { + pCmd->hashedTableNames = taosArrayInit(4, POINTER_BYTES); + } + + if (pCmd->hashedTableNames) { + char* tb = strdup(name); + taosArrayPush(pCmd->hashedTableNames, &tb); + } } else { tFilePage* pdata = (tFilePage*) pv; pVgroupIdList = taosArrayInit((size_t) pdata->num, sizeof(int32_t)); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 604af969da..ec4f2c1daf 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1609,10 +1609,6 @@ void destroyTableNameList(SInsertStatementParam* pInsertParam) { tfree(pInsertParam->pTableNameList); } -static void freeElem(void* p) { - tfree(*(char**)p); -} - void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) { SSqlObj *pSql = (SSqlObj*)taosAcquireRef(tscObjRef, id); pCmd->command = 0; @@ -1628,10 +1624,6 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) { tfree(pCmd->insertParam.tagData.data); pCmd->insertParam.tagData.dataLen = 0; - if (pCmd->hashedTableNames) { - taosArrayDestroyEx(&pCmd->hashedTableNames, freeElem); - } - tscFreeQueryInfo(pCmd, clearCachedMeta, id); pCmd->pTableMetaMap = tscCleanupTableMetaMap(pCmd->pTableMetaMap); taosReleaseRef(tscObjRef, id); -- GitLab