Merge pull request #18398 from taosdata/fix/TS-2139
fix: query failed issue caused of db dropped
This commit is contained in:
commit
6a1ec6946c
|
@ -69,7 +69,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
} else {
|
} else {
|
||||||
SDBVgInfo *vgInfo = taosMemoryCalloc(1, sizeof(SDBVgInfo));
|
SDBVgInfo *vgInfo = taosMemoryCalloc(1, sizeof(SDBVgInfo));
|
||||||
if (NULL == vgInfo) {
|
if (NULL == vgInfo) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vgInfo->vgVersion = rsp->vgVersion;
|
vgInfo->vgVersion = rsp->vgVersion;
|
||||||
|
@ -81,7 +82,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
if (NULL == vgInfo->vgHash) {
|
if (NULL == vgInfo->vgHash) {
|
||||||
taosMemoryFree(vgInfo);
|
taosMemoryFree(vgInfo);
|
||||||
tscError("hash init[%d] failed", rsp->vgNum);
|
tscError("hash init[%d] failed", rsp->vgNum);
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < rsp->vgNum; ++j) {
|
for (int32_t j = 0; j < rsp->vgNum; ++j) {
|
||||||
|
@ -90,7 +92,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
tscError("hash push failed, errno:%d", errno);
|
tscError("hash push failed, errno:%d", errno);
|
||||||
taosHashCleanup(vgInfo->vgHash);
|
taosHashCleanup(vgInfo->vgHash);
|
||||||
taosMemoryFree(vgInfo);
|
taosMemoryFree(vgInfo);
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,12 +101,14 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
goto _return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
tFreeSUseDbBatchRsp(&batchUseRsp);
|
tFreeSUseDbBatchRsp(&batchUseRsp);
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalog *pCatalog) {
|
static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalog *pCatalog) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
#include "systable.h"
|
||||||
|
|
||||||
static void setErrno(SRequestObj* pRequest, int32_t code) {
|
static void setErrno(SRequestObj* pRequest, int32_t code) {
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
|
@ -326,6 +327,17 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||||
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
|
|
||||||
|
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||||
|
.requestId = pRequest->requestId,
|
||||||
|
.requestObjRefId = pRequest->self,
|
||||||
|
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
|
||||||
|
catalogRefreshDBVgInfo(pCatalog, &conn, dbFName);
|
||||||
|
snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||||
|
catalogRefreshDBVgInfo(pCatalog, &conn, dbFName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2537,24 +2537,22 @@ int32_t tDeserializeSUseDbRspImp(SDecoder *pDecoder, SUseDbRsp *pRsp) {
|
||||||
if (tDecodeI16(pDecoder, &pRsp->hashSuffix) < 0) return -1;
|
if (tDecodeI16(pDecoder, &pRsp->hashSuffix) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pRsp->hashMethod) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pRsp->hashMethod) < 0) return -1;
|
||||||
|
|
||||||
if (pRsp->vgNum <= 0) {
|
if (pRsp->vgNum > 0) {
|
||||||
return 0;
|
pRsp->pVgroupInfos = taosArrayInit(pRsp->vgNum, sizeof(SVgroupInfo));
|
||||||
}
|
if (pRsp->pVgroupInfos == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
pRsp->pVgroupInfos = taosArrayInit(pRsp->vgNum, sizeof(SVgroupInfo));
|
for (int32_t i = 0; i < pRsp->vgNum; ++i) {
|
||||||
if (pRsp->pVgroupInfos == NULL) {
|
SVgroupInfo vgInfo = {0};
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
if (tDecodeI32(pDecoder, &vgInfo.vgId) < 0) return -1;
|
||||||
return -1;
|
if (tDecodeU32(pDecoder, &vgInfo.hashBegin) < 0) return -1;
|
||||||
}
|
if (tDecodeU32(pDecoder, &vgInfo.hashEnd) < 0) return -1;
|
||||||
|
if (tDecodeSEpSet(pDecoder, &vgInfo.epSet) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pRsp->vgNum; ++i) {
|
if (tDecodeI32(pDecoder, &vgInfo.numOfTable) < 0) return -1;
|
||||||
SVgroupInfo vgInfo = {0};
|
taosArrayPush(pRsp->pVgroupInfos, &vgInfo);
|
||||||
if (tDecodeI32(pDecoder, &vgInfo.vgId) < 0) return -1;
|
}
|
||||||
if (tDecodeU32(pDecoder, &vgInfo.hashBegin) < 0) return -1;
|
|
||||||
if (tDecodeU32(pDecoder, &vgInfo.hashEnd) < 0) return -1;
|
|
||||||
if (tDecodeSEpSet(pDecoder, &vgInfo.epSet) < 0) return -1;
|
|
||||||
if (tDecodeI32(pDecoder, &vgInfo.numOfTable) < 0) return -1;
|
|
||||||
taosArrayPush(pRsp->pVgroupInfos, &vgInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tDecodeI32(pDecoder, &pRsp->errCode) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pRsp->errCode) < 0) return -1;
|
||||||
|
|
|
@ -1076,6 +1076,9 @@ int32_t catalogRefreshTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const S
|
||||||
SCtgTbMetaCtx ctx = {0};
|
SCtgTbMetaCtx ctx = {0};
|
||||||
ctx.pName = (SName*)pTableName;
|
ctx.pName = (SName*)pTableName;
|
||||||
ctx.flag = CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable);
|
ctx.flag = CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable);
|
||||||
|
if (IS_SYS_DBNAME(ctx.pName->dbname)) {
|
||||||
|
CTG_FLAG_SET_SYS_DB(ctx.flag);
|
||||||
|
}
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgRefreshTbMeta(pCtg, pConn, &ctx, NULL, true));
|
CTG_API_LEAVE(ctgRefreshTbMeta(pCtg, pConn, &ctx, NULL, true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -663,6 +663,7 @@ int32_t ctgDropDbCacheEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId)
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation));
|
SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation));
|
||||||
op->opId = CTG_OP_DROP_DB_CACHE;
|
op->opId = CTG_OP_DROP_DB_CACHE;
|
||||||
|
op->syncOp = true;
|
||||||
|
|
||||||
SCtgDropDBMsg *msg = taosMemoryMalloc(sizeof(SCtgDropDBMsg));
|
SCtgDropDBMsg *msg = taosMemoryMalloc(sizeof(SCtgDropDBMsg));
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
|
@ -1612,11 +1613,11 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
|
|
||||||
dbCache = NULL;
|
dbCache = NULL;
|
||||||
|
|
||||||
if (!IS_SYS_DBNAME(dbFName)) {
|
//if (!IS_SYS_DBNAME(dbFName)) {
|
||||||
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
||||||
CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion),
|
CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion),
|
||||||
ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare));
|
ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare));
|
||||||
}
|
//}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
@ -1641,7 +1642,7 @@ int32_t ctgOpDropDbCache(SCtgCacheOperation *operation) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbCache->dbId != msg->dbId) {
|
if (msg->dbId && dbCache->dbId != msg->dbId) {
|
||||||
ctgInfo("dbId already updated, dbFName:%s, dbId:0x%" PRIx64 ", targetId:0x%" PRIx64, msg->dbFName, dbCache->dbId,
|
ctgInfo("dbId already updated, dbFName:%s, dbId:0x%" PRIx64 ", targetId:0x%" PRIx64, msg->dbFName, dbCache->dbId,
|
||||||
msg->dbId);
|
msg->dbId);
|
||||||
goto _return;
|
goto _return;
|
||||||
|
|
Loading…
Reference in New Issue