feat: remove hb of grantInfo
This commit is contained in:
parent
3ebc26e1fb
commit
d281bc70b0
|
@ -110,7 +110,6 @@ enum {
|
|||
HEARTBEAT_KEY_TMQ,
|
||||
HEARTBEAT_KEY_DYN_VIEW,
|
||||
HEARTBEAT_KEY_VIEWINFO,
|
||||
HEARTBEAT_KEY_GRANTINFO,
|
||||
};
|
||||
|
||||
typedef enum _mgmt_table {
|
||||
|
@ -1886,14 +1885,6 @@ int32_t tSerializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp);
|
|||
int32_t tDeserializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp);
|
||||
void tFreeSViewHbRsp(SViewHbRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
int32_t version;
|
||||
uint32_t flags;
|
||||
} SGrantHbRsp;
|
||||
|
||||
int32_t tSerializeSGrantHbRsp(void* buf, int32_t bufLen, SGrantHbRsp* pRsp);
|
||||
int32_t tDeserializeSGrantHbRsp(void* buf, int32_t bufLen, SGrantHbRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
int32_t numOfTables;
|
||||
int32_t numOfVgroup;
|
||||
|
|
|
@ -343,8 +343,6 @@ int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableVersion** stables, u
|
|||
|
||||
int32_t catalogGetExpiredViews(SCatalog* pCtg, SViewVersion** views, uint32_t* num, SDynViewVersion** dynViewVersion);
|
||||
|
||||
int32_t catalogGetExpiredGrants(SCatalog* pCtg, SGrantVersion** grants, uint32_t* num);
|
||||
|
||||
int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbCacheInfo** dbs, uint32_t* num);
|
||||
|
||||
int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_t* num);
|
||||
|
@ -367,8 +365,6 @@ int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, SUserAuthInfo *p
|
|||
|
||||
int32_t catalogChkAuthFromCache(SCatalog* pCtg, SUserAuthInfo* pAuth, SUserAuthRes* pRes, bool* exists);
|
||||
|
||||
int32_t catalogChkGrant(SCatalog* pCtg, EGrantType grant);
|
||||
|
||||
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
|
||||
|
||||
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet* epSet);
|
||||
|
@ -388,7 +384,6 @@ int32_t catalogRemoveViewMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId
|
|||
int32_t catalogUpdateDynViewVer(SCatalog* pCtg, SDynViewVersion* pVer);
|
||||
|
||||
int32_t catalogUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg);
|
||||
int32_t catalogUpdateGrantInfo(SCatalog* pCtg, SGrantHbRsp* pMsg);
|
||||
|
||||
int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg);
|
||||
|
||||
|
|
|
@ -327,28 +327,6 @@ static int32_t hbProcessViewInfoRsp(void *value, int32_t valueLen, struct SCatal
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t hbProcessGrantInfoRsp(void *value, int32_t valueLen, struct SCatalog *pCatalog) {
|
||||
int32_t code = 0;
|
||||
|
||||
SGrantHbRsp *hbRsp = taosMemoryCalloc(1, sizeof(SGrantHbRsp));
|
||||
if (!hbRsp) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tDeserializeSGrantHbRsp(value, valueLen, hbRsp) != 0) {
|
||||
taosMemoryFree(hbRsp);
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tscDebug("hb to update grant info, version:%d, flags:%u", hbRsp->version, hbRsp->flags);
|
||||
|
||||
catalogUpdateGrantInfo(pCatalog, hbRsp);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void hbProcessQueryRspKvs(int32_t kvNum, SArray* pKvs, struct SCatalog *pCatalog, SAppHbMgr *pAppHbMgr) {
|
||||
for (int32_t i = 0; i < kvNum; ++i) {
|
||||
SKv *kv = taosArrayGet(pKvs, i);
|
||||
|
@ -399,14 +377,6 @@ static void hbProcessQueryRspKvs(int32_t kvNum, SArray* pKvs, struct SCatalog *p
|
|||
hbProcessViewInfoRsp(kv->value, kv->valueLen, pCatalog);
|
||||
break;
|
||||
}
|
||||
case HEARTBEAT_KEY_GRANTINFO: {
|
||||
if (kv->valueLen <= 0 || NULL == kv->value) {
|
||||
tscError("invalid grant info, len:%d, value:%p", kv->valueLen, kv->value);
|
||||
break;
|
||||
}
|
||||
hbProcessGrantInfoRsp(kv->value, kv->valueLen, pCatalog);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
tscError("invalid hb key type:%d", kv->key);
|
||||
|
@ -895,48 +865,6 @@ int32_t hbGetExpiredViewInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t hbGetExpiredGrantInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) {
|
||||
SGrantVersion *grants = NULL;
|
||||
uint32_t grantNum = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
code = catalogGetExpiredGrants(pCatalog, &grants, &grantNum);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (grantNum <= 0) {
|
||||
taosMemoryFree(grants);
|
||||
return code;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < grantNum; ++i) {
|
||||
SGrantVersion *gv = &grants[i];
|
||||
gv->version = htonl(gv->version);
|
||||
}
|
||||
|
||||
tscDebug("hb got %d expired grant, valueLen:%d", grantNum, (int32_t)(sizeof(SGrantVersion) * grantNum));
|
||||
|
||||
if (!req->info) {
|
||||
req->info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||
if (!req->info) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(grants);
|
||||
return code;
|
||||
taosMemoryFree(grants);
|
||||
}
|
||||
}
|
||||
|
||||
SKv kv = {
|
||||
.key = HEARTBEAT_KEY_GRANTINFO,
|
||||
.valueLen = sizeof(SGrantVersion) * grantNum,
|
||||
.value = grants,
|
||||
};
|
||||
taosHashPut(req->info, &kv.key, sizeof(kv.key), &kv, sizeof(kv));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t hbGetAppInfo(int64_t clusterId, SClientHbReq *req) {
|
||||
SAppHbReq *pApp = taosHashGet(clientHbMgr.appSummary, &clusterId, sizeof(clusterId));
|
||||
if (NULL != pApp) {
|
||||
|
@ -999,11 +927,6 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
|
|||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
code = hbGetExpiredGrantInfo(connKey, pCatalog, req);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
req->app.appId = 0;
|
||||
|
|
|
@ -9334,34 +9334,3 @@ void tFreeSViewHbRsp(SViewHbRsp *pRsp) {
|
|||
|
||||
taosArrayDestroy(pRsp->pViewRsp);
|
||||
}
|
||||
|
||||
int32_t tSerializeSGrantHbRsp(void *buf, int32_t bufLen, SGrantHbRsp *pRsp) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI32v(&encoder, pRsp->version) < 0) return -1;
|
||||
if (tEncodeU32v(&encoder, pRsp->flags) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSGrantHbRsp(void *buf, int32_t bufLen, SGrantHbRsp *pRsp) {
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, buf, bufLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI32v(&decoder, &pRsp->version) < 0) return -1;
|
||||
if (tDecodeU32v(&decoder, &pRsp->flags) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
|
@ -43,7 +43,6 @@
|
|||
|
||||
int32_t mndProcessConfigGrantReq(SMnode * pMnode, SRpcMsg * pReq, SMCfgClusterReq * pCfg);
|
||||
int32_t mndProcessUpdGrantLog(SMnode * pMnode, SRpcMsg * pReq, SArray * pMachines, SGrantState * pState);
|
||||
int32_t mndValidateGrant(SMnode * pMnode, SGrantVersion * pGrantVersion, void **ppRsp, int32_t *pRspLen);
|
||||
int32_t mndGrantGetLastState(SMnode * pMnode, SGrantState * pState);
|
||||
SGrantLogObj *mndAcquireGrant(SMnode * pMnode, void **ppIter);
|
||||
void mndReleaseGrant(SMnode * pMnode, SGrantLogObj * pGrant, void *pIter);
|
||||
|
|
|
@ -606,16 +606,6 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
}
|
||||
break;
|
||||
}
|
||||
case HEARTBEAT_KEY_GRANTINFO: {
|
||||
void *rspMsg = NULL;
|
||||
int32_t rspLen = 0;
|
||||
mndValidateGrant(pMnode, kv->value, &rspMsg, &rspLen);
|
||||
if (rspMsg && rspLen > 0) {
|
||||
SKv kv1 = {.key = HEARTBEAT_KEY_GRANTINFO, .valueLen = rspLen, .value = rspMsg};
|
||||
taosArrayPush(hbRsp.info, &kv1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
mError("invalid kv key:%d", kv->key);
|
||||
|
|
|
@ -39,7 +39,6 @@ extern "C" {
|
|||
#define CTG_MAX_COMMAND_LEN 512
|
||||
#define CTG_DEFAULT_CACHE_MON_MSEC 5000
|
||||
#define CTG_CLEAR_CACHE_ROUND_TB_NUM 3000
|
||||
#define CGT_GRANT_ID 0
|
||||
|
||||
#define CTG_RENT_SLOT_SECOND 1.5
|
||||
|
||||
|
@ -70,7 +69,6 @@ typedef enum {
|
|||
CTG_CI_UDF,
|
||||
CTG_CI_SVR_VER,
|
||||
CTG_CI_VIEW,
|
||||
CTG_CI_GRANT_INFO,
|
||||
CTG_CI_MAX_VALUE,
|
||||
} CTG_CACHE_ITEM;
|
||||
|
||||
|
@ -103,8 +101,6 @@ enum {
|
|||
CTG_OP_DROP_TB_INDEX,
|
||||
CTG_OP_UPDATE_VIEW_META,
|
||||
CTG_OP_DROP_VIEW_META,
|
||||
CTG_OP_UPDATE_GRANT_INFO,
|
||||
CTG_OP_DROP_GRANT_INFO,
|
||||
CTG_OP_CLEAR_CACHE,
|
||||
CTG_OP_MAX
|
||||
};
|
||||
|
@ -127,7 +123,6 @@ typedef enum {
|
|||
CTG_TASK_GET_TB_HASH_BATCH,
|
||||
CTG_TASK_GET_TB_TAG,
|
||||
CTG_TASK_GET_VIEW,
|
||||
CTG_TASK_GET_GRANT_INFO,
|
||||
} CTG_TASK_TYPE;
|
||||
|
||||
typedef enum {
|
||||
|
@ -321,18 +316,12 @@ typedef struct SCtgUserAuth {
|
|||
uint64_t userCacheSize;
|
||||
} SCtgUserAuth;
|
||||
|
||||
typedef struct SCtgGrantCache {
|
||||
SRWLatch lock;
|
||||
SGrantHbRsp grantInfo;
|
||||
} SCtgGrantCache;
|
||||
|
||||
typedef struct SCatalog {
|
||||
uint64_t clusterId;
|
||||
bool stopUpdate;
|
||||
SDynViewVersion dynViewVer;
|
||||
SHashObj* userCache; // key:user, value:SCtgUserAuth
|
||||
SHashObj* dbCache; // key:dbname, value:SCtgDBCache
|
||||
SCtgGrantCache grantCache;
|
||||
SCtgRentMgmt dbRent;
|
||||
SCtgRentMgmt stbRent;
|
||||
SCtgRentMgmt viewRent;
|
||||
|
@ -381,7 +370,6 @@ typedef struct SCtgJob {
|
|||
int32_t tbCfgNum;
|
||||
int32_t svrVerNum;
|
||||
int32_t viewNum;
|
||||
int32_t grantNum;
|
||||
} SCtgJob;
|
||||
|
||||
typedef struct SCtgMsgCtx {
|
||||
|
@ -560,15 +548,6 @@ typedef struct SCtgDropViewMetaMsg {
|
|||
uint64_t viewId;
|
||||
} SCtgDropViewMetaMsg;
|
||||
|
||||
typedef struct SCtgUpdateGrantInfoMsg {
|
||||
SCatalog* pCtg;
|
||||
SGrantHbRsp* pRsp;
|
||||
} SCtgUpdateGrantInfoMsg;
|
||||
|
||||
typedef struct SCtgDropGrantInfoMsg {
|
||||
SCatalog* pCtg;
|
||||
} SCtgDropGrantInfoMsg;
|
||||
|
||||
typedef struct SCtgCacheOperation {
|
||||
int32_t opId;
|
||||
void* data;
|
||||
|
@ -931,7 +910,6 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation* action);
|
|||
int32_t ctgOpDropStbMeta(SCtgCacheOperation* action);
|
||||
int32_t ctgOpDropTbMeta(SCtgCacheOperation* action);
|
||||
int32_t ctgOpDropViewMeta(SCtgCacheOperation* action);
|
||||
int32_t ctgOpDropGrantInfo(SCtgCacheOperation* action);
|
||||
int32_t ctgOpUpdateUser(SCtgCacheOperation* action);
|
||||
int32_t ctgOpUpdateEpset(SCtgCacheOperation* operation);
|
||||
int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char* dbFName, SCtgDBCache** pCache);
|
||||
|
@ -967,10 +945,8 @@ int32_t ctgUpdateRentStbVersion(SCatalog *pCtg, char *dbFName, char *tbName, uin
|
|||
SCtgTbCache *pCache);
|
||||
int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName, uint64_t dbId, uint64_t viewId,
|
||||
SCtgViewCache *pCache);
|
||||
// int32_t ctgUpdateRentGrantVersion(SCatalog* pCtg, int32_t grantId, SGrantHbRsp* pGrant);
|
||||
int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool syncReq);
|
||||
int32_t ctgUpdateViewMetaToCache(SCatalog *pCtg, SViewMetaRsp *pRsp, bool syncReq);
|
||||
int32_t ctgUpdateGrantInfoToCache(SCatalog *pCtg, SGrantHbRsp *pRsp, bool syncReq);
|
||||
int32_t ctgStartUpdateThread();
|
||||
int32_t ctgRelaunchGetTbMetaTask(SCtgTask* pTask);
|
||||
void ctgReleaseVgInfoToCache(SCatalog* pCtg, SCtgDBCache* dbCache);
|
||||
|
@ -980,7 +956,6 @@ int32_t ctgOpDropTbIndex(SCtgCacheOperation* operation);
|
|||
int32_t ctgOpUpdateTbIndex(SCtgCacheOperation* operation);
|
||||
int32_t ctgOpClearCache(SCtgCacheOperation* operation);
|
||||
int32_t ctgOpUpdateViewMeta(SCtgCacheOperation *operation);
|
||||
int32_t ctgOpUpdateGrantInfo(SCtgCacheOperation *operation);
|
||||
int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char* tableName, int32_t* tbType);
|
||||
int32_t ctgGetTbHashVgroupFromCache(SCatalog* pCtg, const SName* pTableName, SVgroupInfo** pVgroup);
|
||||
int32_t ctgGetViewsFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgViewsCtx *ctx, int32_t dbIdx,
|
||||
|
@ -1040,12 +1015,10 @@ void ctgResetTbMetaTask(SCtgTask* pTask);
|
|||
void ctgFreeDbCache(SCtgDBCache* dbCache);
|
||||
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2);
|
||||
int32_t ctgViewVersionSortCompare(const void* key1, const void* key2);
|
||||
// int32_t ctgGrantVersionSortCompare(const void* key1, const void* key2);
|
||||
int32_t ctgDbCacheInfoSortCompare(const void* key1, const void* key2);
|
||||
int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2);
|
||||
int32_t ctgDbCacheInfoSearchCompare(const void* key1, const void* key2);
|
||||
int32_t ctgViewVersionSearchCompare(const void* key1, const void* key2);
|
||||
// int32_t ctgGrantVersionSearchCompare(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);
|
||||
|
|
|
@ -353,39 +353,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgChkGrant(SCatalog* pCtg, EGrantType grant) {
|
||||
int32_t code = 0;
|
||||
int32_t flag = 0;
|
||||
SCtgGrantCache* pCache = &pCtg->grantCache;
|
||||
|
||||
CTG_LOCK(CTG_READ, &pCache->lock);
|
||||
switch (grant) {
|
||||
case TSDB_GRANT_ALL: {
|
||||
flag = pCache->grantInfo.flags & GRANT_ALL_FLAG;
|
||||
break;
|
||||
}
|
||||
case TSDB_GRANT_AUDIT: {
|
||||
flag = pCache->grantInfo.flags & GRANT_AUDIT_FLAG;
|
||||
break;
|
||||
}
|
||||
case TSDB_GRANT_CSV: {
|
||||
flag = pCache->grantInfo.flags & GRANT_CSV_FLAG;
|
||||
break;
|
||||
}
|
||||
case TSDB_GRANT_VIEW: {
|
||||
flag = pCache->grantInfo.flags & GRANT_VIEW_FLAG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CTG_UNLOCK(CTG_READ, &pCache->lock);
|
||||
|
||||
if (flag) code = TSDB_CODE_GRANT_EXPIRED;
|
||||
|
||||
_return:
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, int32_t* tbType) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
|
@ -1546,24 +1513,6 @@ int32_t catalogGetExpiredViews(SCatalog* pCtg, SViewVersion** views, uint32_t* n
|
|||
CTG_API_LEAVE(ctgMetaRentGet(&pCtg->viewRent, (void**)views, num, sizeof(SViewVersion)));
|
||||
}
|
||||
|
||||
int32_t catalogGetExpiredGrants(SCatalog* pCtg, SGrantVersion** grants, uint32_t* num) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
if (NULL == pCtg || NULL == grants || NULL == num) {
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
*num = 1;
|
||||
*grants = taosMemoryCalloc(*num, sizeof(SGrantVersion));
|
||||
if (!(*grants)) {
|
||||
ctgError("calloc %d grantVersion failed", *num);
|
||||
CTG_API_LEAVE(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
(*grants)[0].version = pCtg->grantCache.grantInfo.version;
|
||||
|
||||
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbCacheInfo** dbs, uint32_t* num) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
@ -1726,21 +1675,6 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t catalogChkGrant(SCatalog* pCtg, EGrantType grant) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
if (NULL == pCtg) {
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
CTG_ERR_JRET(ctgChkGrant(pCtg, grant));
|
||||
|
||||
_return:
|
||||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo* pConn, char** pVersion) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
@ -1811,22 +1745,6 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t catalogUpdateGrantInfo(SCatalog* pCtg, SGrantHbRsp* pMsg) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
if (NULL == pCtg || NULL == pMsg) {
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
CTG_ERR_JRET(ctgUpdateGrantInfoToCache(pCtg, pMsg, true));
|
||||
|
||||
_return:
|
||||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {{CTG_OP_UPDATE_VGROUP, "update v
|
|||
{CTG_OP_DROP_TB_INDEX, "drop tbIndex", ctgOpDropTbIndex},
|
||||
{CTG_OP_UPDATE_VIEW_META, "update viewMeta", ctgOpUpdateViewMeta},
|
||||
{CTG_OP_DROP_VIEW_META, "drop viewMeta", ctgOpDropViewMeta},
|
||||
{CTG_OP_UPDATE_GRANT_INFO, "update grantInfo", ctgOpUpdateGrantInfo},
|
||||
{CTG_OP_DROP_GRANT_INFO, "drop grantInfo", ctgOpDropGrantInfo},
|
||||
{CTG_OP_CLEAR_CACHE, "clear cache", ctgOpClearCache}};
|
||||
|
||||
SCtgCacheItemInfo gCtgStatItem[CTG_CI_MAX_VALUE] = {
|
||||
|
@ -160,15 +158,6 @@ int32_t ctgGetDBCache(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache)
|
|||
CTG_RET(ctgAcquireDBCacheImpl(pCtg, dbFName, pCache, false));
|
||||
}
|
||||
|
||||
int32_t ctgAcquireGrantCache(SCatalog *pCtg, SCtgGrantCache **ppCache) {
|
||||
CTG_LOCK(CTG_READ, &pCtg->grantCache.lock);
|
||||
*ppCache = &pCtg->grantCache;
|
||||
CTG_CACHE_HIT_INC(CTG_CI_GRANT_INFO, 1);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void ctgReleaseGrantCache(SCatalog *pCtg, SCtgGrantCache *pCache) { CTG_UNLOCK(CTG_READ, &pCache->lock); }
|
||||
|
||||
void ctgReleaseVgInfoToCache(SCatalog *pCtg, SCtgDBCache *dbCache) {
|
||||
ctgRUnlockVgInfo(dbCache);
|
||||
ctgReleaseDBCache(pCtg, dbCache);
|
||||
|
@ -1334,33 +1323,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgUpdateGrantInfoEnqueue(SCatalog *pCtg, SGrantHbRsp *pRsp, bool syncOp) {
|
||||
int32_t code = 0;
|
||||
SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation));
|
||||
op->opId = CTG_OP_UPDATE_GRANT_INFO;
|
||||
op->syncOp = syncOp;
|
||||
|
||||
SCtgUpdateGrantInfoMsg *msg = taosMemoryMalloc(sizeof(SCtgUpdateGrantInfoMsg));
|
||||
if (NULL == msg) {
|
||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateGrantInfoMsg));
|
||||
taosMemoryFree(op);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
msg->pCtg = pCtg;
|
||||
msg->pRsp = pRsp;
|
||||
|
||||
op->data = msg;
|
||||
|
||||
CTG_ERR_RET(ctgEnqueue(pCtg, op));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_return:
|
||||
|
||||
taosMemoryFree(pRsp);
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgDropViewMetaEnqueue(SCatalog *pCtg, const char *dbFName, uint64_t dbId, const char *viewName, uint64_t viewId, bool syncOp) {
|
||||
int32_t code = 0;
|
||||
SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation));
|
||||
|
@ -1732,21 +1694,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgWriteGrantInfoToCache(SCatalog *pCtg, SGrantHbRsp *pRsp) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SCtgGrantCache *pCache = &pCtg->grantCache;
|
||||
|
||||
CTG_LOCK(CTG_WRITE, &pCache->lock);
|
||||
pCache->grantInfo = *pRsp;
|
||||
CTG_UNLOCK(CTG_WRITE, &pCache->lock);
|
||||
|
||||
ctgDebug("grant info updated to cache, flags:%u, version:%d", pRsp->flags, pRsp->version);
|
||||
|
||||
_return:
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgUpdateTbMetaToCache(SCatalog *pCtg, STableMetaOutput *pOut, bool syncReq) {
|
||||
STableMetaOutput *pOutput = NULL;
|
||||
int32_t code = 0;
|
||||
|
@ -1768,10 +1715,6 @@ int32_t ctgUpdateViewMetaToCache(SCatalog *pCtg, SViewMetaRsp *pRsp, bool syncRe
|
|||
CTG_RET(ctgUpdateViewMetaEnqueue(pCtg, pRsp, syncReq));
|
||||
}
|
||||
|
||||
int32_t ctgUpdateGrantInfoToCache(SCatalog *pCtg, SGrantHbRsp *pRsp, bool syncReq) {
|
||||
CTG_RET(ctgUpdateGrantInfoEnqueue(pCtg, pRsp, syncReq));
|
||||
}
|
||||
|
||||
|
||||
void ctgClearAllHandles(void) {
|
||||
SCatalog *pCtg = NULL;
|
||||
|
@ -2507,43 +2450,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgOpUpdateGrantInfo(SCtgCacheOperation *operation) {
|
||||
int32_t code = 0;
|
||||
SCtgUpdateGrantInfoMsg *msg = operation->data;
|
||||
SCatalog *pCtg = msg->pCtg;
|
||||
SGrantHbRsp *pRsp = msg->pRsp;
|
||||
SCtgGrantCache *pGrantCache = NULL;
|
||||
|
||||
taosMemoryFreeClear(msg);
|
||||
|
||||
if (pCtg->stopUpdate) {
|
||||
goto _return;
|
||||
}
|
||||
|
||||
code = ctgWriteGrantInfoToCache(pCtg, pRsp);
|
||||
|
||||
_return:
|
||||
|
||||
taosMemoryFree(pRsp);
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgOpDropGrantInfo(SCtgCacheOperation *operation) {
|
||||
int32_t code = 0;
|
||||
SCtgDropGrantInfoMsg *msg = operation->data;
|
||||
SCatalog *pCtg = msg->pCtg;
|
||||
|
||||
if (pCtg->stopUpdate) {
|
||||
goto _return;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
||||
taosMemoryFreeClear(msg);
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
void ctgClearFreeCache(SCtgCacheOperation *operation) {
|
||||
SCtgClearCacheMsg *msg = operation->data;
|
||||
SCatalog *pCtg = msg->pCtg;
|
||||
|
|
|
@ -2142,10 +2142,6 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
|||
int32_t code = 0;
|
||||
int32_t numOfRows = 0;
|
||||
|
||||
// if ((code = catalogChkGrant(pCxt->pComCxt->pCatalog, TSDB_GRANT_CSV)) < 0) {
|
||||
// return code;
|
||||
// }
|
||||
|
||||
// init only for file
|
||||
if (NULL == pStmt->pTableCxtHashObj) {
|
||||
pStmt->pTableCxtHashObj =
|
||||
|
|
Loading…
Reference in New Issue