提交 c30ab489 编写于 作者: X xywang

fix: super table info not removed after dropped by another client

上级 918e12b8
...@@ -294,6 +294,7 @@ typedef struct { ...@@ -294,6 +294,7 @@ typedef struct {
SQueryInfo *active; // current active query info SQueryInfo *active; // current active query info
int32_t batchSize; // for parameter ('?') binding and batch processing int32_t batchSize; // for parameter ('?') binding and batch processing
int32_t resColumnId; int32_t resColumnId;
SArray *hashedTableNames;
} SSqlCmd; } SSqlCmd;
typedef struct { typedef struct {
......
...@@ -336,6 +336,7 @@ void tscAsyncResultOnError(SSqlObj* pSql) { ...@@ -336,6 +336,7 @@ void tscAsyncResultOnError(SSqlObj* pSql) {
} }
int tscSendMsgToServer(SSqlObj *pSql); int tscSendMsgToServer(SSqlObj *pSql);
void tscClearTableMeta(SSqlObj *pSql);
void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)param); SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)param);
...@@ -355,6 +356,10 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -355,6 +356,10 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
size_t sz = strlen(tscGetErrorMsgPayload(&sub->cmd)); size_t sz = strlen(tscGetErrorMsgPayload(&sub->cmd));
tscAllocPayload(&pSql->cmd, (int)sz + 1); tscAllocPayload(&pSql->cmd, (int)sz + 1);
memcpy(tscGetErrorMsgPayload(&pSql->cmd), tscGetErrorMsgPayload(&sub->cmd), sz); 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) {
tscClearTableMeta(pSql);
}
} }
goto _error; goto _error;
} }
...@@ -421,3 +426,13 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -421,3 +426,13 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
tscAsyncResultOnError(pSql); tscAsyncResultOnError(pSql);
taosReleaseRef(tscObjRef, pSql->self); taosReleaseRef(tscObjRef, pSql->self);
} }
void tscClearTableMeta(SSqlObj *pSql) {
SSqlCmd* pCmd = &pSql->cmd;
int32_t n = taosArrayGetSize(pCmd->hashedTableNames);
for (int32_t i = 0; i < n; i++) {
char *t = taosArrayGetP(pCmd->hashedTableNames, i);
taosHashRemove(UTIL_GET_TABLEMETA(pSql), t, strlen(t));
}
}
...@@ -9434,6 +9434,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -9434,6 +9434,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd);
pCmd->pTableMetaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); pCmd->pTableMetaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
pCmd->hashedTableNames = taosArrayInit(4, POINTER_BYTES);
tableNameList = taosArrayInit(4, sizeof(SName)); tableNameList = taosArrayInit(4, sizeof(SName));
size_t size = taosArrayGetSize(pInfo->list); size_t size = taosArrayGetSize(pInfo->list);
...@@ -9501,6 +9502,9 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -9501,6 +9502,9 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char* t = strdup(name); char* t = strdup(name);
taosArrayPush(pVgroupList, &t); taosArrayPush(pVgroupList, &t);
tscDebug("0x%"PRIx64" failed to retrieve stable %s vgroup id list in cache, try fetch from mnode", pSql->self, name); 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);
} else { } else {
tFilePage* pdata = (tFilePage*) pv; tFilePage* pdata = (tFilePage*) pv;
pVgroupIdList = taosArrayInit((size_t) pdata->num, sizeof(int32_t)); pVgroupIdList = taosArrayInit((size_t) pdata->num, sizeof(int32_t));
......
...@@ -1609,6 +1609,10 @@ void destroyTableNameList(SInsertStatementParam* pInsertParam) { ...@@ -1609,6 +1609,10 @@ void destroyTableNameList(SInsertStatementParam* pInsertParam) {
tfree(pInsertParam->pTableNameList); tfree(pInsertParam->pTableNameList);
} }
static void freeElem(void* p) {
tfree(*(char**)p);
}
void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) { void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) {
SSqlObj *pSql = (SSqlObj*)taosAcquireRef(tscObjRef, id); SSqlObj *pSql = (SSqlObj*)taosAcquireRef(tscObjRef, id);
pCmd->command = 0; pCmd->command = 0;
...@@ -1624,6 +1628,10 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) { ...@@ -1624,6 +1628,10 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) {
tfree(pCmd->insertParam.tagData.data); tfree(pCmd->insertParam.tagData.data);
pCmd->insertParam.tagData.dataLen = 0; pCmd->insertParam.tagData.dataLen = 0;
if (pCmd->hashedTableNames) {
taosArrayDestroyEx(&pCmd->hashedTableNames, freeElem);
}
tscFreeQueryInfo(pCmd, clearCachedMeta, id); tscFreeQueryInfo(pCmd, clearCachedMeta, id);
pCmd->pTableMetaMap = tscCleanupTableMetaMap(pCmd->pTableMetaMap); pCmd->pTableMetaMap = tscCleanupTableMetaMap(pCmd->pTableMetaMap);
taosReleaseRef(tscObjRef, id); taosReleaseRef(tscObjRef, id);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册