enh: support drop table with uid

This commit is contained in:
kailixu 2024-09-19 12:58:30 +08:00
parent ec3178a1aa
commit 07abb97495
2 changed files with 36 additions and 10 deletions

View File

@ -1913,6 +1913,7 @@ static int32_t ctgHandleGetTbNamesRsp(SCtgTaskReq* tReq, int32_t reqType, const
SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx);
SCtgTbNamesCtx* ctx = (SCtgTbNamesCtx*)pTask->taskCtx;
bool taskDone = false;
bool lock = false;
if (NULL == pMsgCtx) {
ctgError("fail to get task msgCtx, taskType:%d", pTask->type);
@ -1930,6 +1931,11 @@ static int32_t ctgHandleGetTbNamesRsp(SCtgTaskReq* tReq, int32_t reqType, const
SName* pName = NULL;
CTG_ERR_JRET(ctgGetFetchName(ctx->pNames, pFetch, &pName));
if (reqType == TDMT_VND_TABLE_NAME) {
taosWLockLatch(&ctx->lock);
lock = true;
}
CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target));
switch (reqType) {
@ -1955,7 +1961,7 @@ static int32_t ctgHandleGetTbNamesRsp(SCtgTaskReq* tReq, int32_t reqType, const
}
ctgTaskDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d, vgId:%d",
tNameGetTableName(pName), flag, vgInfo->vgId);
*vgId = vgInfo->vgId;
// *vgId = 100; //vgInfo->vgId;
if (i > 0) atomic_add_fetch_32(&ctx->fetchNum, 1);
code = ctgGetTbMetaFromVnode(pCtg, pConn, pName, vgInfo, NULL, tReq);
if (code) {
@ -2046,7 +2052,7 @@ static int32_t ctgHandleGetTbNamesRsp(SCtgTaskReq* tReq, int32_t reqType, const
(int32_t)taosArrayGetSize(ctx->pResList));
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
}
// taosWLockLatch(ctx->lock);
pRes->code = 0;
pRes->pRes = pOut->tbMeta;
pOut->tbMeta = NULL;
@ -2067,14 +2073,26 @@ _return:
ctgTaskError("fail to get the %dth res in pResList, resNum:%d", pFetch->resIdx,
(int32_t)taosArrayGetSize(ctx->pResList));
} else {
pRes->code = code;
pRes->pRes = NULL;
ctgTaskError("Get table %d.%s.%s meta failed with error %s", pName->acctId, pName->dbname, pName->tname,
tstrerror(code));
if (0 == atomic_sub_fetch_32(&ctx->fetchNum, 1)) {
TSWAP(pTask->res, ctx->pResList);
taskDone = true;
}
if (TDMT_VND_TABLE_NAME == reqType) {
if (taskDone == true) {
if (pRes->pRes) {
code = 0; // already get tbMeta from one request, reset code to 0
} else {
pRes->code = code;
}
}
} else {
pRes->pRes == NULL;
pRes->code = code;
}
if (taskDone == true) {
ctgTaskError("Get table %d.%s.%s meta failed with error %s", pName->acctId, pName->dbname, pName->tname,
tstrerror(code));
}
}
}
@ -2085,6 +2103,10 @@ _return:
}
}
if (lock) {
taosWUnLockLatch(&ctx->lock);
}
CTG_RET(code);
}

View File

@ -1054,6 +1054,7 @@ int32_t getTableNameFromCache(SParseMetaCache* pMetaCache, const SName* pName, c
}
const STableMeta* pMeta = NULL;
code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableName, (void**)&pMeta);
if (!pMeta) code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
if (TSDB_CODE_SUCCESS == code) {
int32_t metaSize =
sizeof(STableMeta) + sizeof(SSchema) * (pMeta->tableInfo.numOfColumns + pMeta->tableInfo.numOfTags);
@ -1176,11 +1177,14 @@ int32_t getDbTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pNam
for (int32_t i = 0; i < vgSize; ++i) {
uint32_t hashValue =
taosGetTbHashVal(fullName, fullTbLen, pDbCfg->hashMethod, pDbCfg->hashPrefix, pDbCfg->hashSuffix);
void* pVg = taosArraySearch(pVgArray, &hashValue, ctgHashValueComp, TD_EQ);
// void* pVg = taosArraySearch(pVgArray, &hashValue, ctgHashValueComp, TD_EQ);
SVgroupInfo* pVg = taosArrayGet(pVgArray, i);
if (pVg) {
memcpy(pVgroup, pVg, sizeof(SVgroupInfo));
code = TSDB_CODE_SUCCESS;
break;
if (hashValue >= pVg->hashBegin && hashValue <= pVg->hashEnd) {
memcpy(pVgroup, pVg, sizeof(SVgroupInfo));
code = TSDB_CODE_SUCCESS;
break;
}
}
}
}