Merge pull request #15771 from taosdata/enh/ctgPerf
enh: improve catalog performance
This commit is contained in:
commit
bcce0d1aac
|
@ -3055,6 +3055,7 @@ int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
|
|||
int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
|
||||
|
||||
typedef struct {
|
||||
int32_t msgIdx;
|
||||
int32_t msgType;
|
||||
int32_t msgLen;
|
||||
void* msg;
|
||||
|
@ -3068,6 +3069,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int32_t reqType;
|
||||
int32_t msgIdx;
|
||||
int32_t msgLen;
|
||||
int32_t rspCode;
|
||||
void* msg;
|
||||
|
|
|
@ -58,12 +58,17 @@ typedef struct SDbInfo {
|
|||
int64_t dbId;
|
||||
} SDbInfo;
|
||||
|
||||
typedef struct STablesReq {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
SArray* pTables;
|
||||
} STablesReq;
|
||||
|
||||
typedef struct SCatalogReq {
|
||||
SArray* pDbVgroup; // element is db full name
|
||||
SArray* pDbCfg; // element is db full name
|
||||
SArray* pDbInfo; // element is db full name
|
||||
SArray* pTableMeta; // element is SNAME
|
||||
SArray* pTableHash; // element is SNAME
|
||||
SArray* pTableMeta; // element is STablesReq
|
||||
SArray* pTableHash; // element is STablesReq
|
||||
SArray* pUdf; // element is udf name
|
||||
SArray* pIndex; // element is index name
|
||||
SArray* pUser; // element is SUserAuthInfo
|
||||
|
|
|
@ -1922,7 +1922,7 @@ _OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str,
|
||||
int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str,
|
||||
int32_t acctId, char* db) {
|
||||
SName name;
|
||||
|
||||
|
@ -1957,20 +1957,33 @@ int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, i
|
|||
return -1;
|
||||
}
|
||||
|
||||
taosArrayPush(pList, &name);
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName);
|
||||
|
||||
STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName));
|
||||
if (pDb) {
|
||||
taosArrayPush(pDb->pTables, &name);
|
||||
} else {
|
||||
STablesReq db;
|
||||
db.pTables = taosArrayInit(20, sizeof(SName));
|
||||
strcpy(db.dbFName, dbFName);
|
||||
taosArrayPush(db.pTables, &name);
|
||||
taosHashPut(pHash, dbFName, strlen(dbFName), &db, sizeof(db));
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq) {
|
||||
*pReq = taosArrayInit(10, sizeof(SName));
|
||||
if (NULL == *pReq) {
|
||||
SHashObj* pHash = taosHashInit(3, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
if (NULL == pHash) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
bool inEscape = false;
|
||||
int32_t code = 0;
|
||||
void *pIter = NULL;
|
||||
|
||||
int32_t vIdx = 0;
|
||||
int32_t vPos[2];
|
||||
|
@ -1985,7 +1998,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
|
|||
vLen[vIdx] = i - vPos[vIdx];
|
||||
}
|
||||
|
||||
code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
|
||||
code = appendTbToReq(pHash, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
|
||||
if (code) {
|
||||
goto _return;
|
||||
}
|
||||
|
@ -2035,7 +2048,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
|
|||
vLen[vIdx] = i - vPos[vIdx];
|
||||
}
|
||||
|
||||
code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
|
||||
code = appendTbToReq(pHash, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
|
||||
if (code) {
|
||||
goto _return;
|
||||
}
|
||||
|
@ -2067,14 +2080,31 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
|
|||
goto _return;
|
||||
}
|
||||
|
||||
int32_t dbNum = taosHashGetSize(pHash);
|
||||
*pReq = taosArrayInit(dbNum, sizeof(STablesReq));
|
||||
pIter = taosHashIterate(pHash, NULL);
|
||||
while (pIter) {
|
||||
STablesReq* pDb = (STablesReq*)pIter;
|
||||
taosArrayPush(*pReq, pDb);
|
||||
pIter = taosHashIterate(pHash, pIter);
|
||||
}
|
||||
|
||||
taosHashCleanup(pHash);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
terrno = TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
|
||||
taosArrayDestroy(*pReq);
|
||||
*pReq = NULL;
|
||||
pIter = taosHashIterate(pHash, NULL);
|
||||
while (pIter) {
|
||||
STablesReq* pDb = (STablesReq*)pIter;
|
||||
taosArrayDestroy(pDb->pTables);
|
||||
pIter = taosHashIterate(pHash, pIter);
|
||||
}
|
||||
|
||||
taosHashCleanup(pHash);
|
||||
|
||||
return terrno;
|
||||
}
|
||||
|
|
|
@ -84,6 +84,9 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
req.msgIdx = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgIdx);
|
||||
|
||||
req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgType);
|
||||
|
||||
|
@ -111,6 +114,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
} else {
|
||||
rsp.rspCode = 0;
|
||||
}
|
||||
rsp.msgIdx = req.msgIdx;
|
||||
rsp.reqType = reqMsg.msgType;
|
||||
rsp.msgLen = reqMsg.info.rspLen;
|
||||
rsp.msg = reqMsg.info.rsp;
|
||||
|
@ -136,6 +140,8 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->reqType);
|
||||
offset += sizeof(p->reqType);
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgIdx);
|
||||
offset += sizeof(p->msgIdx);
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen);
|
||||
offset += sizeof(p->msgLen);
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode);
|
||||
|
|
|
@ -273,6 +273,9 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgIdx);
|
||||
|
||||
req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgType);
|
||||
|
||||
|
@ -301,6 +304,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
break;
|
||||
}
|
||||
|
||||
rsp.msgIdx = req.msgIdx;
|
||||
rsp.reqType = reqMsg.msgType;
|
||||
rsp.msgLen = reqMsg.contLen;
|
||||
rsp.rspCode = reqMsg.code;
|
||||
|
@ -327,6 +331,8 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->reqType);
|
||||
offset += sizeof(p->reqType);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->msgIdx);
|
||||
offset += sizeof(p->msgIdx);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->msgLen);
|
||||
offset += sizeof(p->msgLen);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->rspCode);
|
||||
|
|
|
@ -32,6 +32,7 @@ extern "C" {
|
|||
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
|
||||
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
|
||||
#define CTG_DEFAULT_BATCH_NUM 64
|
||||
#define CTG_DEFAULT_FETCH_NUM 8
|
||||
|
||||
#define CTG_RENT_SLOT_SECOND 1.5
|
||||
|
||||
|
@ -80,6 +81,8 @@ typedef enum {
|
|||
CTG_TASK_GET_UDF,
|
||||
CTG_TASK_GET_USER,
|
||||
CTG_TASK_GET_SVR_VER,
|
||||
CTG_TASK_GET_TB_META_BATCH,
|
||||
CTG_TASK_GET_TB_HASH_BATCH,
|
||||
} CTG_TASK_TYPE;
|
||||
|
||||
typedef enum {
|
||||
|
@ -110,6 +113,23 @@ typedef struct SCtgTbMetaCtx {
|
|||
int32_t flag;
|
||||
} SCtgTbMetaCtx;
|
||||
|
||||
typedef struct SCtgFetch {
|
||||
int32_t dbIdx;
|
||||
int32_t tbIdx;
|
||||
int32_t fetchIdx;
|
||||
int32_t resIdx;
|
||||
int32_t flag;
|
||||
SCtgTbCacheInfo tbInfo;
|
||||
int32_t vgId;
|
||||
} SCtgFetch;
|
||||
|
||||
typedef struct SCtgTbMetasCtx {
|
||||
int32_t fetchNum;
|
||||
SArray* pNames;
|
||||
SArray* pResList;
|
||||
SArray* pFetchs;
|
||||
} SCtgTbMetasCtx;
|
||||
|
||||
typedef struct SCtgTbIndexCtx {
|
||||
SName* pName;
|
||||
} SCtgTbIndexCtx;
|
||||
|
@ -137,6 +157,14 @@ typedef struct SCtgTbHashCtx {
|
|||
SName* pName;
|
||||
} SCtgTbHashCtx;
|
||||
|
||||
typedef struct SCtgTbHashsCtx {
|
||||
int32_t fetchNum;
|
||||
SArray* pNames;
|
||||
SArray* pResList;
|
||||
SArray* pFetchs;
|
||||
} SCtgTbHashsCtx;
|
||||
|
||||
|
||||
typedef struct SCtgIndexCtx {
|
||||
char indexFName[TSDB_INDEX_FNAME_LEN];
|
||||
} SCtgIndexCtx;
|
||||
|
@ -211,6 +239,7 @@ typedef struct SCtgBatch {
|
|||
SRequestConnInfo conn;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
SArray* pTaskIds;
|
||||
SArray* pMsgIdxs;
|
||||
} SCtgBatch;
|
||||
|
||||
typedef struct SCtgJob {
|
||||
|
@ -218,6 +247,7 @@ typedef struct SCtgJob {
|
|||
int32_t batchId;
|
||||
SHashObj* pBatchs;
|
||||
SArray* pTasks;
|
||||
int32_t subTaskNum;
|
||||
int32_t taskDone;
|
||||
SMetaData jobRes;
|
||||
int32_t jobResCode;
|
||||
|
@ -258,6 +288,7 @@ typedef struct SCtgTaskCallbackParam {
|
|||
SArray* taskId;
|
||||
int32_t reqType;
|
||||
int32_t batchId;
|
||||
SArray* msgIdx;
|
||||
} SCtgTaskCallbackParam;
|
||||
|
||||
|
||||
|
@ -276,6 +307,7 @@ typedef struct SCtgTask {
|
|||
int32_t taskId;
|
||||
SCtgJob* pJob;
|
||||
void* taskCtx;
|
||||
SArray* msgCtxs;
|
||||
SCtgMsgCtx msgCtx;
|
||||
int32_t code;
|
||||
void* res;
|
||||
|
@ -286,9 +318,14 @@ typedef struct SCtgTask {
|
|||
SHashObj* pBatchs;
|
||||
} SCtgTask;
|
||||
|
||||
typedef struct SCtgTaskReq {
|
||||
SCtgTask* pTask;
|
||||
int32_t msgIdx;
|
||||
} SCtgTaskReq;
|
||||
|
||||
typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*);
|
||||
typedef int32_t (*ctgLanchTaskFp)(SCtgTask*);
|
||||
typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTask*, int32_t, const SDataBuf *, int32_t);
|
||||
typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTaskReq*, int32_t, const SDataBuf *, int32_t);
|
||||
typedef int32_t (*ctgDumpTaskResFp)(SCtgTask*);
|
||||
typedef int32_t (*ctgCloneTaskResFp)(SCtgTask*, void**);
|
||||
typedef int32_t (*ctgCompTaskFp)(SCtgTask*, void*, bool*);
|
||||
|
@ -487,6 +524,8 @@ typedef struct SCtgOperation {
|
|||
#define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB))
|
||||
#define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE))
|
||||
|
||||
#define CTG_GET_TASK_MSGCTX(_task, _id) (((CTG_TASK_GET_TB_META_BATCH == (_task)->type) || (CTG_TASK_GET_TB_HASH_BATCH == (_task)->type)) ? taosArrayGet((_task)->msgCtxs, (_id)) : &(_task)->msgCtx)
|
||||
|
||||
#define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema))
|
||||
|
||||
#define CTG_TABLE_NOT_EXIST(code) (code == CTG_ERR_CODE_TABLE_NOT_EXIST)
|
||||
|
@ -586,6 +625,7 @@ int32_t ctgdShowCacheInfo(void);
|
|||
|
||||
int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq);
|
||||
int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
||||
int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx, int32_t *fetchIdx, int32_t baseResIdx, SArray* pList);
|
||||
|
||||
int32_t ctgOpUpdateVgroup(SCtgCacheOperation *action);
|
||||
int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *action);
|
||||
|
@ -631,7 +671,7 @@ int32_t ctgGetTbHashVgroupFromCache(SCatalog *pCtg, const SName *pTableName, SVg
|
|||
|
||||
|
||||
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target);
|
||||
int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTask* pTask);
|
||||
int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTaskReq* tReq);
|
||||
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask);
|
||||
int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray **out, SCtgTask* pTask);
|
||||
int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask);
|
||||
|
@ -639,9 +679,9 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
|||
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, STableIndex* out, SCtgTask* pTask);
|
||||
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *funcName, SFuncInfo *out, SCtgTask* pTask);
|
||||
int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask);
|
||||
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask);
|
||||
int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMetaOutput* out, SCtgTask* pTask);
|
||||
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask);
|
||||
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTaskReq* tReq);
|
||||
int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMetaOutput* out, SCtgTaskReq* tReq);
|
||||
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTaskReq* tReq);
|
||||
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask);
|
||||
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask);
|
||||
int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask);
|
||||
|
@ -664,6 +704,7 @@ void ctgFreeJob(void* job);
|
|||
void ctgFreeHandleImpl(SCatalog* pCtg);
|
||||
void ctgFreeVgInfo(SDBVgInfo *vgInfo);
|
||||
int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup);
|
||||
int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *dbInfo, SCtgTbHashsCtx *pCtx, char* dbFName, SArray* pNames, bool update);
|
||||
void ctgResetTbMetaTask(SCtgTask* pTask);
|
||||
void ctgFreeDbCache(SCtgDBCache *dbCache);
|
||||
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2);
|
||||
|
@ -672,8 +713,11 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2);
|
|||
int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2);
|
||||
void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
|
||||
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
|
||||
int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target);
|
||||
char * ctgTaskTypeStr(CTG_TASK_TYPE type);
|
||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId);
|
||||
int32_t ctgGetTablesReqNum(SArray *pList);
|
||||
int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t *fetchIdx, int32_t resIdx, int32_t flag);
|
||||
int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes);
|
||||
void ctgFreeSTableIndex(void *info);
|
||||
void ctgClearSubTaskRes(SCtgSubRes *pRes);
|
||||
|
@ -682,6 +726,7 @@ void ctgClearHandle(SCatalog* pCtg);
|
|||
void ctgFreeTbCacheImpl(SCtgTbCache *pCache);
|
||||
int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName);
|
||||
int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup);
|
||||
SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
|
||||
|
||||
|
||||
extern SCatalogMgmt gCtgMgmt;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -242,7 +242,6 @@ int32_t ctgAcquireTbMetaFromCache(SCatalog* pCtg, char *dbFName, char* tbName, S
|
|||
goto _return;
|
||||
}
|
||||
|
||||
int32_t sz = 0;
|
||||
pCache = taosHashAcquire(dbCache->tbCache, tbName, strlen(tbName));
|
||||
if (NULL == pCache) {
|
||||
ctgDebug("tb %s not in cache, dbFName:%s", tbName, dbFName);
|
||||
|
@ -282,7 +281,6 @@ int32_t ctgAcquireStbMetaFromCache(SCatalog* pCtg, char *dbFName, uint64_t suid,
|
|||
goto _return;
|
||||
}
|
||||
|
||||
int32_t sz = 0;
|
||||
char* stName = taosHashAcquire(dbCache->stbCache, &suid, sizeof(suid));
|
||||
if (NULL == stName) {
|
||||
ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", suid, dbFName);
|
||||
|
@ -2152,6 +2150,254 @@ int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMet
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t ctgGetTbMetaBFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, SArray** pResList) {
|
||||
int32_t tbNum = taosArrayGetSize(ctx->pNames);
|
||||
SName* fName = taosArrayGet(ctx->pNames, 0);
|
||||
int32_t fIdx = 0;
|
||||
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
SName* pName = taosArrayGet(ctx->pNames, i);
|
||||
SCtgTbMetaCtx nctx = {0};
|
||||
nctx.flag = CTG_FLAG_UNKNOWN_STB;
|
||||
nctx.pName = pName;
|
||||
|
||||
if (IS_SYS_DBNAME(pName->dbname)) {
|
||||
CTG_FLAG_SET_SYS_DB(nctx.flag);
|
||||
}
|
||||
|
||||
STableMeta *pTableMeta = NULL;
|
||||
CTG_ERR_RET(ctgReadTbMetaFromCache(pCtg, &nctx, &pTableMeta));
|
||||
SMetaRes res = {0};
|
||||
|
||||
if (pTableMeta) {
|
||||
if (CTG_FLAG_MATCH_STB(nctx.flag, pTableMeta->tableType) &&
|
||||
((!CTG_FLAG_IS_FORCE_UPDATE(nctx.flag)) || (CTG_FLAG_IS_SYS_DB(nctx.flag)))) {
|
||||
res.pRes = pTableMeta;
|
||||
} else {
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == res.pRes) {
|
||||
if (NULL == ctx->pFetchs) {
|
||||
ctx->pFetchs = taosArrayInit(tbNum, sizeof(SCtgFetch));
|
||||
}
|
||||
|
||||
if (CTG_FLAG_IS_UNKNOWN_STB(nctx.flag)) {
|
||||
CTG_FLAG_SET_STB(nctx.flag, nctx.tbInfo.tbType);
|
||||
}
|
||||
|
||||
SCtgFetch fetch = {0};
|
||||
fetch.tbIdx = i;
|
||||
fetch.fetchIdx = fIdx++;
|
||||
fetch.flag = nctx.flag;
|
||||
|
||||
taosArrayPush(ctx->pFetchs, &fetch);
|
||||
}
|
||||
|
||||
taosArrayPush(ctx->pResList, &res);
|
||||
}
|
||||
|
||||
if (NULL == ctx->pFetchs) {
|
||||
TSWAP(*pResList, ctx->pResList);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx, int32_t *fetchIdx, int32_t baseResIdx, SArray* pList) {
|
||||
int32_t tbNum = taosArrayGetSize(pList);
|
||||
SName* pName = taosArrayGet(pList, 0);
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
int32_t flag = CTG_FLAG_UNKNOWN_STB;
|
||||
uint64_t lastSuid = 0;
|
||||
STableMeta* lastTableMeta = NULL;
|
||||
|
||||
if (IS_SYS_DBNAME(pName->dbname)) {
|
||||
CTG_FLAG_SET_SYS_DB(flag);
|
||||
strcpy(dbFName, pName->dbname);
|
||||
} else {
|
||||
tNameGetFullDbName(pName, dbFName);
|
||||
}
|
||||
|
||||
SCtgDBCache *dbCache = NULL;
|
||||
SCtgTbCache* pCache = NULL;
|
||||
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
||||
|
||||
if (NULL == dbCache) {
|
||||
ctgDebug("db %s not in cache", dbFName);
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
SName* pName = taosArrayGet(pList, i);
|
||||
|
||||
pCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname));
|
||||
if (NULL == pCache) {
|
||||
ctgDebug("tb %s not in cache, dbFName:%s", pName->tname, dbFName);
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
||||
if (NULL == pCache->pMeta) {
|
||||
ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName);
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
STableMeta* tbMeta = pCache->pMeta;
|
||||
|
||||
SCtgTbMetaCtx nctx = {0};
|
||||
nctx.flag = flag;
|
||||
nctx.tbInfo.inCache = true;
|
||||
nctx.tbInfo.dbId = dbCache->dbId;
|
||||
nctx.tbInfo.suid = tbMeta->suid;
|
||||
nctx.tbInfo.tbType = tbMeta->tableType;
|
||||
|
||||
SMetaRes res = {0};
|
||||
STableMeta* pTableMeta = NULL;
|
||||
if (tbMeta->tableType != TSDB_CHILD_TABLE) {
|
||||
int32_t metaSize = CTG_META_SIZE(tbMeta);
|
||||
pTableMeta = taosMemoryCalloc(1, metaSize);
|
||||
if (NULL == pTableMeta) {
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
memcpy(pTableMeta, tbMeta, metaSize);
|
||||
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, pCache);
|
||||
|
||||
ctgDebug("Got tb %s meta from cache, type:%d, dbFName:%s", pName->tname, tbMeta->tableType, dbFName);
|
||||
|
||||
res.pRes = pTableMeta;
|
||||
taosArrayPush(ctx->pResList, &res);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// PROCESS FOR CHILD TABLE
|
||||
|
||||
if (lastSuid && tbMeta->suid == lastSuid && lastTableMeta) {
|
||||
cloneTableMeta(lastTableMeta, &pTableMeta);
|
||||
memcpy(pTableMeta, tbMeta, sizeof(SCTableMeta));
|
||||
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, pCache);
|
||||
|
||||
ctgDebug("Got tb %s meta from cache, type:%d, dbFName:%s", pName->tname, tbMeta->tableType, dbFName);
|
||||
|
||||
res.pRes = pTableMeta;
|
||||
taosArrayPush(ctx->pResList, &res);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t metaSize = sizeof(SCTableMeta);
|
||||
pTableMeta = taosMemoryCalloc(1, metaSize);
|
||||
if (NULL == pTableMeta) {
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
memcpy(pTableMeta, tbMeta, metaSize);
|
||||
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, pCache);
|
||||
|
||||
ctgDebug("Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s",
|
||||
pName->tname, nctx.tbInfo.tbType, dbFName);
|
||||
|
||||
char* stName = taosHashAcquire(dbCache->stbCache, &pTableMeta->suid, sizeof(pTableMeta->suid));
|
||||
if (NULL == stName) {
|
||||
ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", pTableMeta->suid, dbFName);
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
continue;
|
||||
}
|
||||
|
||||
pCache = taosHashAcquire(dbCache->tbCache, stName, strlen(stName));
|
||||
if (NULL == pCache) {
|
||||
ctgDebug("stb 0x%" PRIx64 " name %s not in cache, dbFName:%s", pTableMeta->suid, stName, dbFName);
|
||||
taosHashRelease(dbCache->stbCache, stName);
|
||||
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
continue;
|
||||
}
|
||||
|
||||
taosHashRelease(dbCache->stbCache, stName);
|
||||
|
||||
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
||||
if (NULL == pCache->pMeta) {
|
||||
ctgDebug("stb 0x%" PRIx64 " meta not in cache, dbFName:%s", pTableMeta->suid, dbFName);
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, pCache);
|
||||
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
STableMeta* stbMeta = pCache->pMeta;
|
||||
if (stbMeta->suid != nctx.tbInfo.suid) {
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, pCache);
|
||||
|
||||
ctgError("stb suid 0x%" PRIx64 " in stbCache mis-match, expected suid 0x%"PRIx64 , stbMeta->suid, nctx.tbInfo.suid);
|
||||
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
metaSize = CTG_META_SIZE(stbMeta);
|
||||
pTableMeta = taosMemoryRealloc(pTableMeta, metaSize);
|
||||
if (NULL == pTableMeta) {
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
memcpy(&pTableMeta->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta));
|
||||
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, pCache);
|
||||
|
||||
res.pRes = pTableMeta;
|
||||
taosArrayPush(ctx->pResList, &res);
|
||||
|
||||
lastSuid = pTableMeta->suid;
|
||||
lastTableMeta = pTableMeta;
|
||||
}
|
||||
|
||||
ctgReleaseDBCache(pCtg, dbCache);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq) {
|
||||
int32_t code = 0;
|
||||
|
|
|
@ -22,9 +22,8 @@
|
|||
|
||||
int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBuf* pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SArray* pTaskId = cbParam->taskId;
|
||||
SCatalog* pCtg = pJob->pCtg;
|
||||
int32_t taskNum = taosArrayGetSize(pTaskId);
|
||||
int32_t taskNum = taosArrayGetSize(cbParam->taskId);
|
||||
SDataBuf taskMsg = *pMsg;
|
||||
int32_t offset = 0;
|
||||
int32_t msgNum = (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) ? ntohl(*(int32_t*)pMsg->pData) : 0;
|
||||
|
@ -42,11 +41,14 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < taskNum; ++i) {
|
||||
int32_t* taskId = taosArrayGet(pTaskId, i);
|
||||
int32_t* taskId = taosArrayGet(cbParam->taskId, i);
|
||||
int32_t* msgIdx = taosArrayGet(cbParam->msgIdx, i);
|
||||
SCtgTask* pTask = taosArrayGet(pJob->pTasks, *taskId);
|
||||
if (msgNum > 0) {
|
||||
rsp.reqType = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.reqType);
|
||||
rsp.msgIdx = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.msgIdx);
|
||||
rsp.msgLen = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.msgLen);
|
||||
rsp.rspCode = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
|
@ -57,7 +59,10 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
taskMsg.msgType = rsp.reqType;
|
||||
taskMsg.pData = rsp.msg;
|
||||
taskMsg.len = rsp.msgLen;
|
||||
|
||||
ASSERT(rsp.msgIdx == *msgIdx);
|
||||
} else {
|
||||
rsp.msgIdx = *msgIdx;
|
||||
rsp.reqType = -1;
|
||||
taskMsg.msgType = -1;
|
||||
taskMsg.pData = NULL;
|
||||
|
@ -65,11 +70,14 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
}
|
||||
|
||||
pTask->pBatchs = pBatchs;
|
||||
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = rsp.msgIdx;
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId,
|
||||
TMSG_INFO(taskMsg.msgType + 1));
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg task %d idx %d start to handle rsp %s", pJob->queryId, pTask->taskId, rsp.msgIdx, TMSG_INFO(taskMsg.msgType + 1));
|
||||
|
||||
(*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode));
|
||||
(*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode));
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||
|
@ -338,7 +346,10 @@ int32_t ctgHandleMsgCallback(void* param, SDataBuf* pMsg, int32_t rspCode) {
|
|||
pTask->pBatchs = pBatchs;
|
||||
#endif
|
||||
|
||||
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, cbParam->reqType, pMsg, rspCode));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||
|
@ -356,7 +367,7 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int32_t msgType,
|
||||
int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, SArray* pMsgIdx, int32_t msgType,
|
||||
SMsgSendInfo** pMsgSendInfo) {
|
||||
int32_t code = 0;
|
||||
SMsgSendInfo* msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
|
@ -376,6 +387,7 @@ int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int3
|
|||
param->refId = pJob->refId;
|
||||
param->taskId = pTaskId;
|
||||
param->batchId = batchId;
|
||||
param->msgIdx = pMsgIdx;
|
||||
|
||||
msgSendInfo->param = param;
|
||||
msgSendInfo->paramFreeFp = ctgFreeMsgSendParam;
|
||||
|
@ -394,10 +406,10 @@ _return:
|
|||
}
|
||||
|
||||
int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob* pJob, SArray* pTaskId, int32_t batchId,
|
||||
char* dbFName, int32_t vgId, int32_t msgType, void* msg, uint32_t msgSize) {
|
||||
SArray* pMsgIdx, char* dbFName, int32_t vgId, int32_t msgType, void* msg, uint32_t msgSize) {
|
||||
int32_t code = 0;
|
||||
SMsgSendInfo* pMsgSendInfo = NULL;
|
||||
CTG_ERR_JRET(ctgMakeMsgSendInfo(pJob, pTaskId, batchId, msgType, &pMsgSendInfo));
|
||||
CTG_ERR_JRET(ctgMakeMsgSendInfo(pJob, pTaskId, batchId, pMsgIdx, msgType, &pMsgSendInfo));
|
||||
|
||||
ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, dbFName, vgId);
|
||||
|
||||
|
@ -428,25 +440,27 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgTask* pTask, int32_t msgType, void* msg,
|
||||
int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgTaskReq* tReq, int32_t msgType, void* msg,
|
||||
uint32_t msgSize) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
SHashObj* pBatchs = pTask->pBatchs;
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
SCtgBatch* pBatch = taosHashGet(pBatchs, &vgId, sizeof(vgId));
|
||||
int32_t taskNum = taosArrayGetSize(pTask->pJob->pTasks);
|
||||
SCtgBatch newBatch = {0};
|
||||
SBatchMsg req = {0};
|
||||
|
||||
SCtgBatch newBatch = {0};
|
||||
SBatchMsg req = {0};
|
||||
|
||||
if (NULL == pBatch) {
|
||||
newBatch.pMsgs = taosArrayInit(taskNum, sizeof(SBatchMsg));
|
||||
newBatch.pTaskIds = taosArrayInit(taskNum, sizeof(int32_t));
|
||||
if (NULL == newBatch.pMsgs || NULL == newBatch.pTaskIds) {
|
||||
newBatch.pMsgs = taosArrayInit(pJob->subTaskNum, sizeof(SBatchMsg));
|
||||
newBatch.pTaskIds = taosArrayInit(pJob->subTaskNum, sizeof(int32_t));
|
||||
newBatch.pMsgIdxs = taosArrayInit(pJob->subTaskNum, sizeof(int32_t));
|
||||
if (NULL == newBatch.pMsgs || NULL == newBatch.pTaskIds || NULL == newBatch.pMsgIdxs) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
newBatch.conn = *pConn;
|
||||
|
||||
req.msgIdx = tReq->msgIdx;
|
||||
req.msgType = msgType;
|
||||
req.msgLen = msgSize;
|
||||
req.msg = msg;
|
||||
|
@ -456,19 +470,31 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
if (NULL == taosArrayPush(newBatch.pTaskIds, &pTask->taskId)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
if (NULL == taosArrayPush(newBatch.pMsgIdxs, &req.msgIdx)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
newBatch.msgSize = sizeof(SBatchReq) + sizeof(req) + msgSize - POINTER_BYTES;
|
||||
|
||||
if (vgId > 0) {
|
||||
SName* pName = NULL;
|
||||
if (TDMT_VND_TABLE_CFG == msgType) {
|
||||
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
pName = ctx->pName;
|
||||
} else if (TDMT_VND_TABLE_META == msgType) {
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
if (CTG_TASK_GET_TB_META_BATCH == pTask->type) {
|
||||
SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx;
|
||||
SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
|
||||
pName = ctgGetFetchName(ctx->pNames, fetch);
|
||||
} else {
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
pName = ctx->pName;
|
||||
}
|
||||
} else {
|
||||
ctgError("invalid vnode msgType %d", msgType);
|
||||
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
tNameGetFullDbName(pName, newBatch.dbFName);
|
||||
}
|
||||
|
||||
newBatch.msgType = (vgId > 0) ? TDMT_VND_BATCH_META : TDMT_MND_BATCH_META;
|
||||
|
@ -484,6 +510,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
req.msgIdx = tReq->msgIdx;
|
||||
req.msgType = msgType;
|
||||
req.msgLen = msgSize;
|
||||
req.msg = msg;
|
||||
|
@ -493,19 +520,32 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
if (NULL == taosArrayPush(pBatch->pTaskIds, &pTask->taskId)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
if (NULL == taosArrayPush(pBatch->pMsgIdxs, &req.msgIdx)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
pBatch->msgSize += sizeof(req) + msgSize - POINTER_BYTES;
|
||||
|
||||
if (vgId > 0) {
|
||||
SName* pName = NULL;
|
||||
if (TDMT_VND_TABLE_CFG == msgType) {
|
||||
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
pName = ctx->pName;
|
||||
} else if (TDMT_VND_TABLE_META == msgType) {
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
if (CTG_TASK_GET_TB_META_BATCH == pTask->type) {
|
||||
SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx;
|
||||
SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
|
||||
pName = ctgGetFetchName(ctx->pNames, fetch);
|
||||
} else {
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
pName = ctx->pName;
|
||||
}
|
||||
} else {
|
||||
ctgError("invalid vnode msgType %d", msgType);
|
||||
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
tNameGetFullDbName(pName, newBatch.dbFName);
|
||||
}
|
||||
|
||||
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId,
|
||||
|
@ -537,6 +577,8 @@ int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg) {
|
|||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SBatchMsg* pReq = taosArrayGet(pBatch->pMsgs, i);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgIdx);
|
||||
offset += sizeof(pReq->msgIdx);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgType);
|
||||
offset += sizeof(pReq->msgType);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgLen);
|
||||
|
@ -564,8 +606,8 @@ int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob* pJob, SHashObj* pBatchs) {
|
|||
ctgDebug("QID:0x%" PRIx64 " ctg start to launch batch %d", pJob->queryId, pBatch->batchId);
|
||||
|
||||
CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg));
|
||||
code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId, pBatch->dbFName, *vgId,
|
||||
pBatch->msgType, msg, pBatch->msgSize);
|
||||
code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId, pBatch->pMsgIdxs,
|
||||
pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize);
|
||||
pBatch->pTaskIds = NULL;
|
||||
CTG_ERR_JRET(code);
|
||||
|
||||
|
@ -603,10 +645,14 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, NULL));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, NULL));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -614,7 +660,7 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -649,10 +695,13 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
|
|||
}
|
||||
|
||||
if (pTask) {
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, NULL));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -660,7 +709,7 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -681,10 +730,11 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
|
|||
}
|
||||
|
||||
int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildUseDBInput* input, SUseDbOutput* out,
|
||||
SCtgTask* pTask) {
|
||||
SCtgTaskReq* tReq) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_USE_DB;
|
||||
SCtgTask* pTask = tReq ? tReq->pTask : NULL;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db);
|
||||
|
@ -700,10 +750,11 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildU
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, input->db));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, input->db));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -711,7 +762,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildU
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -751,10 +802,14 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)dbFName));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)dbFName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -762,7 +817,7 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -802,10 +857,14 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)indexName));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)indexName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -813,7 +872,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -855,11 +914,14 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)tbFName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -867,7 +929,7 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -907,10 +969,14 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)funcName));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)funcName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -918,7 +984,7 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -958,10 +1024,14 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)user));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)user));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -969,7 +1039,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -990,7 +1060,8 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
}
|
||||
|
||||
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* dbFName, char* tbName,
|
||||
STableMetaOutput* out, SCtgTask* pTask) {
|
||||
STableMetaOutput* out, SCtgTaskReq* tReq) {
|
||||
SCtgTask *pTask = tReq ? tReq->pTask : NULL;
|
||||
SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName};
|
||||
char* msg = NULL;
|
||||
SEpSet* pVnodeEpSet = NULL;
|
||||
|
@ -1013,9 +1084,11 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char*
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, tbFName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -1023,7 +1096,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char*
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1044,15 +1117,16 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char*
|
|||
}
|
||||
|
||||
int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMetaOutput* out,
|
||||
SCtgTask* pTask) {
|
||||
SCtgTaskReq* tReq) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
|
||||
return ctgGetTbMetaFromMnodeImpl(pCtg, pConn, dbFName, (char*)pTableName->tname, out, pTask);
|
||||
return ctgGetTbMetaFromMnodeImpl(pCtg, pConn, dbFName, (char*)pTableName->tname, out, tReq);
|
||||
}
|
||||
|
||||
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* vgroupInfo,
|
||||
STableMetaOutput* out, SCtgTask* pTask) {
|
||||
STableMetaOutput* out, SCtgTaskReq* tReq) {
|
||||
SCtgTask *pTask = tReq ? tReq->pTask : NULL;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
int32_t reqType = TDMT_VND_TABLE_META;
|
||||
|
@ -1080,15 +1154,16 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
|
|||
if (NULL == pOut) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
|
||||
|
||||
SRequestConnInfo vConn = {.pTrans = pConn->pTrans,
|
||||
.requestId = pConn->requestId,
|
||||
.requestObjRefId = pConn->requestObjRefId,
|
||||
.mgmtEps = vgroupInfo->epSet};
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, tbFName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
|
@ -1099,7 +1174,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->vgId, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, ctx->vgId, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1142,14 +1217,17 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
|
|||
}
|
||||
|
||||
if (pTask) {
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName));
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, (char*)tbFName));
|
||||
|
||||
SRequestConnInfo vConn = {.pTrans = pConn->pTrans,
|
||||
.requestId = pConn->requestId,
|
||||
.requestObjRefId = pConn->requestObjRefId,
|
||||
.mgmtEps = vgroupInfo->epSet};
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
|
@ -1160,7 +1238,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1201,9 +1279,13 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
|
|||
}
|
||||
|
||||
if (pTask) {
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName));
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, (char*)tbFName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -1211,7 +1293,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1246,10 +1328,13 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou
|
|||
}
|
||||
|
||||
if (pTask) {
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, NULL));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
|
@ -1257,7 +1342,7 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou
|
|||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ void ctgFreeMsgSendParam(void* param) {
|
|||
|
||||
SCtgTaskCallbackParam* pParam = (SCtgTaskCallbackParam*)param;
|
||||
taosArrayDestroy(pParam->taskId);
|
||||
taosArrayDestroy(pParam->msgIdx);
|
||||
|
||||
taosMemoryFree(param);
|
||||
}
|
||||
|
@ -88,6 +89,10 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
|
|||
return "[get user]";
|
||||
case CTG_TASK_GET_SVR_VER:
|
||||
return "[get svr ver]";
|
||||
case CTG_TASK_GET_TB_META_BATCH:
|
||||
return "[bget table meta]";
|
||||
case CTG_TASK_GET_TB_HASH_BATCH:
|
||||
return "[bget table hash]";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
|
@ -460,6 +465,25 @@ void ctgResetTbMetaTask(SCtgTask* pTask) {
|
|||
taosMemoryFreeClear(pTask->res);
|
||||
}
|
||||
|
||||
void ctgFreeBatchMeta(void* meta) {
|
||||
if (NULL == meta) {
|
||||
return;
|
||||
}
|
||||
|
||||
SMetaRes* pRes = (SMetaRes*)meta;
|
||||
taosMemoryFreeClear(pRes->pRes);
|
||||
}
|
||||
|
||||
void ctgFreeBatchHash(void* hash) {
|
||||
if (NULL == hash) {
|
||||
return;
|
||||
}
|
||||
|
||||
SMetaRes* pRes = (SMetaRes*)hash;
|
||||
taosMemoryFreeClear(pRes->pRes);
|
||||
}
|
||||
|
||||
|
||||
void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
||||
switch (type) {
|
||||
case CTG_TASK_GET_QNODE:
|
||||
|
@ -500,6 +524,24 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
|||
taosMemoryFreeClear(*pRes);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_META_BATCH: {
|
||||
SArray* pArray = (SArray*)*pRes;
|
||||
int32_t num = taosArrayGetSize(pArray);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
ctgFreeBatchMeta(taosArrayGet(pArray, i));
|
||||
}
|
||||
*pRes = NULL; // no need to free it
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_HASH_BATCH: {
|
||||
SArray* pArray = (SArray*)*pRes;
|
||||
int32_t num = taosArrayGetSize(pArray);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
ctgFreeBatchHash(taosArrayGet(pArray, i));
|
||||
}
|
||||
*pRes = NULL; // no need to free it
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qError("invalid task type %d", type);
|
||||
break;
|
||||
|
@ -554,6 +596,16 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) {
|
|||
taosMemoryFreeClear(*pRes);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_META_BATCH: {
|
||||
taosArrayDestroyEx(*pRes, ctgFreeBatchMeta);
|
||||
*pRes = NULL;
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_HASH_BATCH: {
|
||||
taosArrayDestroyEx(*pRes, ctgFreeBatchHash);
|
||||
*pRes = NULL;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qError("invalid task type %d", type);
|
||||
break;
|
||||
|
@ -583,12 +635,38 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
|
|||
taosMemoryFreeClear(pTask->taskCtx);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_META_BATCH: {
|
||||
SCtgTbMetasCtx* taskCtx = (SCtgTbMetasCtx*)pTask->taskCtx;
|
||||
taosArrayDestroyEx(taskCtx->pResList, ctgFreeBatchMeta);
|
||||
taosArrayDestroy(taskCtx->pFetchs);
|
||||
// NO NEED TO FREE pNames
|
||||
|
||||
taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeMsgCtx);
|
||||
|
||||
if (pTask->msgCtx.lastOut) {
|
||||
ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.lastOut);
|
||||
pTask->msgCtx.lastOut = NULL;
|
||||
}
|
||||
taosMemoryFreeClear(pTask->taskCtx);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_HASH: {
|
||||
SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx;
|
||||
taosMemoryFreeClear(taskCtx->pName);
|
||||
taosMemoryFreeClear(pTask->taskCtx);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_HASH_BATCH: {
|
||||
SCtgTbHashsCtx* taskCtx = (SCtgTbHashsCtx*)pTask->taskCtx;
|
||||
taosArrayDestroyEx(taskCtx->pResList, ctgFreeBatchHash);
|
||||
taosArrayDestroy(taskCtx->pFetchs);
|
||||
// NO NEED TO FREE pNames
|
||||
|
||||
taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeMsgCtx);
|
||||
|
||||
taosMemoryFreeClear(pTask->taskCtx);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_INDEX: {
|
||||
SCtgTbIndexCtx* taskCtx = (SCtgTbIndexCtx*)pTask->taskCtx;
|
||||
taosMemoryFreeClear(taskCtx->pName);
|
||||
|
@ -679,6 +757,23 @@ int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* targ
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target) {
|
||||
SCtgMsgCtx ctx = {0};
|
||||
|
||||
ctx.reqType = reqType;
|
||||
ctx.out = out;
|
||||
if (target) {
|
||||
ctx.target = strdup(target);
|
||||
if (NULL == ctx.target) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
taosArrayPush(pCtxs, &ctx);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgGetHashFunction(int8_t hashMethod, tableNameHashFp *fp) {
|
||||
switch (hashMethod) {
|
||||
|
@ -780,6 +875,104 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *dbInfo, SCtgTbHashsCtx *pCtx, char* dbFName, SArray* pNames, bool update) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
SMetaRes res = {0};
|
||||
int32_t vgNum = taosHashGetSize(dbInfo->vgHash);
|
||||
if (vgNum <= 0) {
|
||||
ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum);
|
||||
CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED);
|
||||
}
|
||||
|
||||
tableNameHashFp fp = NULL;
|
||||
SVgroupInfo *vgInfo = NULL;
|
||||
|
||||
CTG_ERR_RET(ctgGetHashFunction(dbInfo->hashMethod, &fp));
|
||||
|
||||
int32_t tbNum = taosArrayGetSize(pNames);
|
||||
|
||||
if (1 == vgNum) {
|
||||
void *pIter = taosHashIterate(dbInfo->vgHash, NULL);
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
vgInfo = taosMemoryMalloc(sizeof(SVgroupInfo));
|
||||
if (NULL == vgInfo) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
*vgInfo = *(SVgroupInfo*)pIter;
|
||||
|
||||
ctgDebug("Got tb hash vgroup, vgId:%d, epNum %d, current %s port %d", vgInfo->vgId, vgInfo->epSet.numOfEps,
|
||||
vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port);
|
||||
|
||||
if (update) {
|
||||
SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, tReq->msgIdx);
|
||||
SMetaRes *pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i);
|
||||
pRes->pRes = vgInfo;
|
||||
} else {
|
||||
res.pRes = vgInfo;
|
||||
taosArrayPush(pCtx->pResList, &res);
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char tbFullName[TSDB_TABLE_FNAME_LEN];
|
||||
sprintf(tbFullName, "%s.", dbFName);
|
||||
int32_t offset = strlen(tbFullName);
|
||||
SName* pName = NULL;
|
||||
int32_t tbNameLen = 0;
|
||||
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
pName = taosArrayGet(pNames, i);
|
||||
|
||||
tbNameLen = offset + strlen(pName->tname);
|
||||
strcpy(tbFullName + offset, pName->tname);
|
||||
|
||||
uint32_t hashValue = (*fp)(tbFullName, (uint32_t)tbNameLen);
|
||||
|
||||
void *pIter = taosHashIterate(dbInfo->vgHash, NULL);
|
||||
while (pIter) {
|
||||
vgInfo = pIter;
|
||||
if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) {
|
||||
taosHashCancelIterate(dbInfo->vgHash, pIter);
|
||||
break;
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(dbInfo->vgHash, pIter);
|
||||
vgInfo = NULL;
|
||||
}
|
||||
|
||||
if (NULL == vgInfo) {
|
||||
ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, taosHashGetSize(dbInfo->vgHash));
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
SVgroupInfo* pNewVg = taosMemoryMalloc(sizeof(SVgroupInfo));
|
||||
if (NULL == pNewVg) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
*pNewVg = *vgInfo;
|
||||
|
||||
ctgDebug("Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, vgInfo->epSet.numOfEps,
|
||||
vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port);
|
||||
|
||||
if (update) {
|
||||
SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, tReq->msgIdx);
|
||||
SMetaRes *pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i);
|
||||
pRes->pRes = pNewVg;
|
||||
} else {
|
||||
res.pRes = pNewVg;
|
||||
taosArrayPush(pCtx->pResList, &res);
|
||||
}
|
||||
}
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) {
|
||||
if (*(uint64_t *)key1 < ((SSTableVersion*)key2)->suid) {
|
||||
return -1;
|
||||
|
@ -921,4 +1114,41 @@ int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, cha
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetTablesReqNum(SArray *pList) {
|
||||
if (NULL == pList) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t total = 0;
|
||||
int32_t n = taosArrayGetSize(pList);
|
||||
for (int32_t i = 0; i < n; ++i) {
|
||||
STablesReq *pReq = taosArrayGet(pList, i);
|
||||
total += taosArrayGetSize(pReq->pTables);
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t *fetchIdx, int32_t resIdx, int32_t flag) {
|
||||
if (NULL == (*pFetchs)) {
|
||||
*pFetchs = taosArrayInit(CTG_DEFAULT_FETCH_NUM, sizeof(SCtgFetch));
|
||||
}
|
||||
|
||||
SCtgFetch fetch = {0};
|
||||
fetch.dbIdx = dbIdx;
|
||||
fetch.tbIdx = tbIdx;
|
||||
fetch.fetchIdx = (*fetchIdx)++;
|
||||
fetch.resIdx = resIdx;
|
||||
fetch.flag = flag;
|
||||
|
||||
taosArrayPush(*pFetchs, &fetch);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch) {
|
||||
STablesReq* pReq = (STablesReq*)taosArrayGet(pNames, pFetch->dbIdx);
|
||||
return (SName*)taosArrayGet(pReq->pTables, pFetch->tbIdx);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ typedef struct SMsgBuf {
|
|||
char* buf;
|
||||
} SMsgBuf;
|
||||
|
||||
typedef struct SParseTablesMetaReq {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
SHashObj* pTables;
|
||||
} SParseTablesMetaReq;
|
||||
|
||||
typedef struct SParseMetaCache {
|
||||
SHashObj* pTableMeta; // key is tbFName, element is STableMeta*
|
||||
SHashObj* pDbVgroup; // key is dbFName, element is SArray<SVgroupInfo>*
|
||||
|
@ -95,7 +100,7 @@ int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFun
|
|||
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes);
|
||||
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput);
|
||||
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes);
|
||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache);
|
||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -474,6 +474,24 @@ static int32_t buildDbReq(SHashObj* pDbsHash, SArray** pDbs) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t buildTableReqFromDb(SHashObj* pDbsHash, SArray** pDbs) {
|
||||
if (NULL != pDbsHash) {
|
||||
*pDbs = taosArrayInit(taosHashGetSize(pDbsHash), sizeof(STablesReq));
|
||||
if (NULL == *pDbs) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
SParseTablesMetaReq* p = taosHashIterate(pDbsHash, NULL);
|
||||
while (NULL != p) {
|
||||
STablesReq req = {0};
|
||||
strcpy(req.dbFName, p->dbFName);
|
||||
buildTableReq(p->pTables, &req.pTables);
|
||||
taosArrayPush(*pDbs, &req);
|
||||
p = taosHashIterate(pDbsHash, p);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t buildUserAuthReq(SHashObj* pUserAuthHash, SArray** pUserAuth) {
|
||||
if (NULL != pUserAuthHash) {
|
||||
*pUserAuth = taosArrayInit(taosHashGetSize(pUserAuthHash), sizeof(SUserAuthInfo));
|
||||
|
@ -513,12 +531,12 @@ static int32_t buildUdfReq(SHashObj* pUdfHash, SArray** pUdf) {
|
|||
}
|
||||
|
||||
int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq) {
|
||||
int32_t code = buildTableReq(pMetaCache->pTableMeta, &pCatalogReq->pTableMeta);
|
||||
int32_t code = buildTableReqFromDb(pMetaCache->pTableMeta, &pCatalogReq->pTableMeta);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildDbReq(pMetaCache->pDbVgroup, &pCatalogReq->pDbVgroup);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildTableReq(pMetaCache->pTableVgroup, &pCatalogReq->pTableHash);
|
||||
code = buildTableReqFromDb(pMetaCache->pTableVgroup, &pCatalogReq->pTableHash);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildDbReq(pMetaCache->pDbCfg, &pCatalogReq->pDbCfg);
|
||||
|
@ -587,6 +605,24 @@ static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHa
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t putDbTableDataToCache(const SArray* pDbReq, const SArray* pTableData, SHashObj** pTable) {
|
||||
int32_t ndbs = taosArrayGetSize(pDbReq);
|
||||
int32_t tableNo = 0;
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
STablesReq* pReq = taosArrayGet(pDbReq, i);
|
||||
int32_t ntables = taosArrayGetSize(pReq->pTables);
|
||||
for (int32_t j = 0; j < ntables; ++j) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(taosArrayGet(pReq->pTables, j), fullName);
|
||||
if (TSDB_CODE_SUCCESS != putMetaDataToHash(fullName, strlen(fullName), pTableData, tableNo, pTable)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
++tableNo;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj** pUserAuth) {
|
||||
int32_t nvgs = taosArrayGetSize(pUserAuthReq);
|
||||
for (int32_t i = 0; i < nvgs; ++i) {
|
||||
|
@ -612,12 +648,12 @@ static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHas
|
|||
}
|
||||
|
||||
int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache) {
|
||||
int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, &pMetaCache->pTableMeta);
|
||||
int32_t code = putDbTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, &pMetaCache->pTableMeta);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, &pMetaCache->pDbVgroup);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, &pMetaCache->pTableVgroup);
|
||||
code = putDbTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, &pMetaCache->pTableVgroup);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, &pMetaCache->pDbCfg);
|
||||
|
@ -657,14 +693,38 @@ static int32_t reserveTableReqInCache(int32_t acctId, const char* pDb, const cha
|
|||
return reserveTableReqInCacheImpl(fullName, len, pTables);
|
||||
}
|
||||
|
||||
static int32_t reserveTableReqInDbCacheImpl(int32_t acctId, const char* pDb, const char* pTable, SHashObj* pDbs) {
|
||||
SParseTablesMetaReq req = {0};
|
||||
int32_t len = snprintf(req.dbFName, sizeof(req.dbFName), "%d.%s", acctId, pDb);
|
||||
int32_t code = reserveTableReqInCache(acctId, pDb, pTable, &req.pTables);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = taosHashPut(pDbs, req.dbFName, len, &req, sizeof(SParseTablesMetaReq));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t reserveTableReqInDbCache(int32_t acctId, const char* pDb, const char* pTable, SHashObj** pDbs) {
|
||||
if (NULL == *pDbs) {
|
||||
*pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
if (NULL == *pDbs) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
char fullName[TSDB_DB_FNAME_LEN];
|
||||
int32_t len = snprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb);
|
||||
SParseTablesMetaReq* pReq = taosHashGet(*pDbs, fullName, len);
|
||||
if (NULL == pReq) {
|
||||
return reserveTableReqInDbCacheImpl(acctId, pDb, pTable, *pDbs);
|
||||
}
|
||||
return reserveTableReqInCache(acctId, pDb, pTable, &pReq->pTables);
|
||||
}
|
||||
|
||||
int32_t reserveTableMetaInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) {
|
||||
return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableMeta);
|
||||
return reserveTableReqInDbCache(acctId, pDb, pTable, &pMetaCache->pTableMeta);
|
||||
}
|
||||
|
||||
int32_t reserveTableMetaInCacheExt(const SName* pName, SParseMetaCache* pMetaCache) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
return reserveTableReqInCacheImpl(fullName, strlen(fullName), &pMetaCache->pTableMeta);
|
||||
return reserveTableReqInDbCache(pName->acctId, pName->dbname, pName->tname, &pMetaCache->pTableMeta);
|
||||
}
|
||||
|
||||
int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) {
|
||||
|
@ -711,13 +771,11 @@ int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName,
|
|||
}
|
||||
|
||||
int32_t reserveTableVgroupInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) {
|
||||
return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableVgroup);
|
||||
return reserveTableReqInDbCache(acctId, pDb, pTable, &pMetaCache->pTableVgroup);
|
||||
}
|
||||
|
||||
int32_t reserveTableVgroupInCacheExt(const SName* pName, SParseMetaCache* pMetaCache) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
return reserveTableReqInCacheImpl(fullName, strlen(fullName), &pMetaCache->pTableVgroup);
|
||||
return reserveTableReqInDbCache(pName->acctId, pName->dbname, pName->tname, &pMetaCache->pTableVgroup);
|
||||
}
|
||||
|
||||
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup) {
|
||||
|
@ -919,10 +977,24 @@ int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||
taosHashCleanup(pMetaCache->pTableMeta);
|
||||
void destoryParseTablesMetaReqHash(SHashObj* pHash) {
|
||||
SParseTablesMetaReq* p = taosHashIterate(pHash, NULL);
|
||||
while (NULL != p) {
|
||||
taosHashCleanup(p->pTables);
|
||||
p = taosHashIterate(pHash, p);
|
||||
}
|
||||
taosHashCleanup(pHash);
|
||||
}
|
||||
|
||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) {
|
||||
if (request) {
|
||||
destoryParseTablesMetaReqHash(pMetaCache->pTableMeta);
|
||||
destoryParseTablesMetaReqHash(pMetaCache->pTableVgroup);
|
||||
} else {
|
||||
taosHashCleanup(pMetaCache->pTableMeta);
|
||||
taosHashCleanup(pMetaCache->pTableVgroup);
|
||||
}
|
||||
taosHashCleanup(pMetaCache->pDbVgroup);
|
||||
taosHashCleanup(pMetaCache->pTableVgroup);
|
||||
taosHashCleanup(pMetaCache->pDbCfg);
|
||||
taosHashCleanup(pMetaCache->pDbInfo);
|
||||
taosHashCleanup(pMetaCache->pUserAuth);
|
||||
|
|
|
@ -85,13 +85,13 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
|
|||
if (IS_VAR_DATA_TYPE(pVal->node.resType.type)) {
|
||||
taosMemoryFreeClear(pVal->datum.p);
|
||||
}
|
||||
|
||||
|
||||
if (pParam->is_null && 1 == *(pParam->is_null)) {
|
||||
pVal->node.resType.type = TSDB_DATA_TYPE_NULL;
|
||||
pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t inputSize = (NULL != pParam->length ? *(pParam->length) : tDataTypes[pParam->buffer_type].bytes);
|
||||
pVal->node.resType.type = pParam->buffer_type;
|
||||
pVal->node.resType.bytes = inputSize;
|
||||
|
@ -187,7 +187,7 @@ int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCatalogReq(&metaCache, pCatalogReq);
|
||||
}
|
||||
destoryParseMetaCache(&metaCache);
|
||||
destoryParseMetaCache(&metaCache, true);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata
|
|||
code = analyseSemantic(pCxt, pQuery, &metaCache);
|
||||
}
|
||||
}
|
||||
destoryParseMetaCache(&metaCache);
|
||||
destoryParseMetaCache(&metaCache, false);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -472,12 +472,16 @@ class MockCatalogServiceImpl {
|
|||
|
||||
int32_t getAllTableMeta(SArray* pTableMetaReq, SArray** pTableMetaData) const {
|
||||
if (NULL != pTableMetaReq) {
|
||||
int32_t ntables = taosArrayGetSize(pTableMetaReq);
|
||||
*pTableMetaData = taosArrayInit(ntables, sizeof(SMetaRes));
|
||||
for (int32_t i = 0; i < ntables; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.code = catalogGetTableMeta((const SName*)taosArrayGet(pTableMetaReq, i), (STableMeta**)&res.pRes);
|
||||
taosArrayPush(*pTableMetaData, &res);
|
||||
int32_t ndbs = taosArrayGetSize(pTableMetaReq);
|
||||
*pTableMetaData = taosArrayInit(ndbs, sizeof(SMetaRes));
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
STablesReq* pReq = (STablesReq*)taosArrayGet(pTableMetaReq, i);
|
||||
int32_t ntables = taosArrayGetSize(pReq->pTables);
|
||||
for (int32_t j = 0; j < ntables; ++j) {
|
||||
SMetaRes res = {0};
|
||||
res.code = catalogGetTableMeta((const SName*)taosArrayGet(pReq->pTables, j), (STableMeta**)&res.pRes);
|
||||
taosArrayPush(*pTableMetaData, &res);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -485,13 +489,17 @@ class MockCatalogServiceImpl {
|
|||
|
||||
int32_t getAllTableVgroup(SArray* pTableVgroupReq, SArray** pTableVgroupData) const {
|
||||
if (NULL != pTableVgroupReq) {
|
||||
int32_t ntables = taosArrayGetSize(pTableVgroupReq);
|
||||
*pTableVgroupData = taosArrayInit(ntables, sizeof(SMetaRes));
|
||||
for (int32_t i = 0; i < ntables; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(SVgroupInfo));
|
||||
res.code = catalogGetTableHashVgroup((const SName*)taosArrayGet(pTableVgroupReq, i), (SVgroupInfo*)res.pRes);
|
||||
taosArrayPush(*pTableVgroupData, &res);
|
||||
int32_t ndbs = taosArrayGetSize(pTableVgroupReq);
|
||||
*pTableVgroupData = taosArrayInit(ndbs, sizeof(SMetaRes));
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
STablesReq* pReq = (STablesReq*)taosArrayGet(pTableVgroupReq, i);
|
||||
int32_t ntables = taosArrayGetSize(pReq->pTables);
|
||||
for (int32_t j = 0; j < ntables; ++j) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(SVgroupInfo));
|
||||
res.code = catalogGetTableHashVgroup((const SName*)taosArrayGet(pReq->pTables, j), (SVgroupInfo*)res.pRes);
|
||||
taosArrayPush(*pTableVgroupData, &res);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -677,12 +685,17 @@ int32_t MockCatalogService::catalogGetAllMeta(const SCatalogReq* pCatalogReq, SM
|
|||
return impl_->catalogGetAllMeta(pCatalogReq, pMetaData);
|
||||
}
|
||||
|
||||
void MockCatalogService::destoryTablesReq(void* p) {
|
||||
STablesReq* pRes = (STablesReq*)p;
|
||||
taosArrayDestroy(pRes->pTables);
|
||||
}
|
||||
|
||||
void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) {
|
||||
taosArrayDestroy(pReq->pDbVgroup);
|
||||
taosArrayDestroy(pReq->pDbCfg);
|
||||
taosArrayDestroy(pReq->pDbInfo);
|
||||
taosArrayDestroy(pReq->pTableMeta);
|
||||
taosArrayDestroy(pReq->pTableHash);
|
||||
taosArrayDestroyEx(pReq->pTableMeta, destoryTablesReq);
|
||||
taosArrayDestroyEx(pReq->pTableHash, destoryTablesReq);
|
||||
taosArrayDestroy(pReq->pUdf);
|
||||
taosArrayDestroy(pReq->pIndex);
|
||||
taosArrayDestroy(pReq->pUser);
|
||||
|
|
|
@ -50,6 +50,7 @@ struct MockTableMeta {
|
|||
class MockCatalogServiceImpl;
|
||||
class MockCatalogService {
|
||||
public:
|
||||
static void destoryTablesReq(void* p);
|
||||
static void destoryCatalogReq(SCatalogReq* pReq);
|
||||
static void destoryMetaRes(void* p);
|
||||
static void destoryMetaArrayRes(void* p);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "mockCatalogService.h"
|
||||
|
@ -20,6 +22,7 @@
|
|||
#include "parInt.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
@ -63,7 +66,9 @@ class InsertTest : public Test {
|
|||
|
||||
int32_t runAsync() {
|
||||
cxt_.async = true;
|
||||
unique_ptr<SParseMetaCache, void (*)(SParseMetaCache*)> metaCache(new SParseMetaCache(), _destoryParseMetaCache);
|
||||
bool request = true;
|
||||
unique_ptr<SParseMetaCache, function<void(SParseMetaCache*)> > metaCache(
|
||||
new SParseMetaCache(), std::bind(_destoryParseMetaCache, _1, cref(request)));
|
||||
code_ = parseInsertSyntax(&cxt_, &res_, metaCache.get());
|
||||
if (code_ != TSDB_CODE_SUCCESS) {
|
||||
cout << "parseInsertSyntax code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||
|
@ -81,6 +86,8 @@ class InsertTest : public Test {
|
|||
unique_ptr<SMetaData, void (*)(SMetaData*)> metaData(new SMetaData(), MockCatalogService::destoryMetaData);
|
||||
g_mockCatalogService->catalogGetAllMeta(catalogReq.get(), metaData.get());
|
||||
|
||||
metaCache.reset(new SParseMetaCache());
|
||||
request = false;
|
||||
code_ = putMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get());
|
||||
if (code_ != TSDB_CODE_SUCCESS) {
|
||||
cout << "putMetaDataToCache code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||
|
@ -144,8 +151,8 @@ class InsertTest : public Test {
|
|||
static const int max_err_len = 1024;
|
||||
static const int max_sql_len = 1024 * 1024;
|
||||
|
||||
static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||
destoryParseMetaCache(pMetaCache);
|
||||
static void _destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) {
|
||||
destoryParseMetaCache(pMetaCache, request);
|
||||
delete pMetaCache;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "parInt.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace testing;
|
||||
|
||||
namespace ParserTest {
|
||||
|
@ -118,8 +119,8 @@ class ParserTestBaseImpl {
|
|||
TEST_INTERFACE_ASYNC_API
|
||||
};
|
||||
|
||||
static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||
destoryParseMetaCache(pMetaCache);
|
||||
static void _destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) {
|
||||
destoryParseMetaCache(pMetaCache, request);
|
||||
delete pMetaCache;
|
||||
}
|
||||
|
||||
|
@ -340,7 +341,9 @@ class ParserTestBaseImpl {
|
|||
doParse(&cxt, query.get());
|
||||
SQuery* pQuery = *(query.get());
|
||||
|
||||
unique_ptr<SParseMetaCache, void (*)(SParseMetaCache*)> metaCache(new SParseMetaCache(), _destoryParseMetaCache);
|
||||
bool request = true;
|
||||
unique_ptr<SParseMetaCache, function<void(SParseMetaCache*)> > metaCache(
|
||||
new SParseMetaCache(), bind(_destoryParseMetaCache, _1, cref(request)));
|
||||
doCollectMetaKey(&cxt, pQuery, metaCache.get());
|
||||
|
||||
unique_ptr<SCatalogReq, void (*)(SCatalogReq*)> catalogReq(new SCatalogReq(),
|
||||
|
@ -353,6 +356,8 @@ class ParserTestBaseImpl {
|
|||
unique_ptr<SMetaData, void (*)(SMetaData*)> metaData(new SMetaData(), MockCatalogService::destoryMetaData);
|
||||
doGetAllMeta(catalogReq.get(), metaData.get());
|
||||
|
||||
metaCache.reset(new SParseMetaCache());
|
||||
request = false;
|
||||
doPutMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get());
|
||||
|
||||
doAuthenticate(&cxt, pQuery, metaCache.get());
|
||||
|
|
|
@ -462,3 +462,5 @@ int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) {
|
|||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -387,10 +387,13 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
|||
|
||||
char * sql = strndup(msg->msg, msg->sqlLen);
|
||||
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql);
|
||||
QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
|
||||
QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
|
||||
QW_ERR_JRET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_return:
|
||||
|
||||
QW_SCH_TASK_DLOG("processQuery end, node:%p, code:%d", node, code);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) {
|
||||
|
|
Loading…
Reference in New Issue