feat: support uniq grant

This commit is contained in:
kailixu 2024-02-02 13:59:45 +08:00
parent 3f061a8460
commit 3e7884a4f7
4 changed files with 12 additions and 14 deletions

View File

@ -146,7 +146,7 @@ typedef struct SSTableVersion {
} SSTableVersion; } SSTableVersion;
typedef struct SGrantVersion { typedef struct SGrantVersion {
int32_t grantId; int64_t grantId;
int32_t version; int32_t version;
} SGrantVersion; } SGrantVersion;

View File

@ -568,6 +568,7 @@ typedef struct SCtgUpdateGrantInfoMsg {
typedef struct SCtgDropGrantInfoMsg { typedef struct SCtgDropGrantInfoMsg {
SCatalog* pCtg; SCatalog* pCtg;
int64_t grantId;
} SCtgDropGrantInfoMsg; } SCtgDropGrantInfoMsg;
typedef struct SCtgCacheOperation { typedef struct SCtgCacheOperation {
@ -1040,10 +1041,12 @@ void ctgResetTbMetaTask(SCtgTask* pTask);
void ctgFreeDbCache(SCtgDBCache* dbCache); void ctgFreeDbCache(SCtgDBCache* dbCache);
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2); int32_t ctgStbVersionSortCompare(const void* key1, const void* key2);
int32_t ctgViewVersionSortCompare(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 ctgDbCacheInfoSortCompare(const void* key1, const void* key2);
int32_t ctgStbVersionSearchCompare(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 ctgDbCacheInfoSearchCompare(const void* key1, const void* key2);
int32_t ctgViewVersionSearchCompare(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); void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target); int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target); int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target);

View File

@ -1739,7 +1739,7 @@ int32_t ctgWriteGrantInfoToCache(SCatalog *pCtg, SGrantHbRsp *pRsp) {
pCache->grantInfo = *pRsp; pCache->grantInfo = *pRsp;
CTG_UNLOCK(CTG_WRITE, &pCache->lock); CTG_UNLOCK(CTG_WRITE, &pCache->lock);
ctgDebug("grant info updated to cache, version"); ctgDebug("grant info updated to cache, flags:%u, version:%d", pRsp->flags, pRsp->version);
CTG_ERR_RET(ctgUpdateRentViewVersion(pCtg, dbFName, viewName, dbCache->dbId, pMeta->viewId, pCache)); CTG_ERR_RET(ctgUpdateRentViewVersion(pCtg, dbFName, viewName, dbCache->dbId, pMeta->viewId, pCache));
@ -2548,7 +2548,10 @@ int32_t ctgOpDropGrantInfo(SCtgCacheOperation *operation) {
goto _return; goto _return;
} }
printf("prop:%s:%d grant %s removed from rent\n"); CTG_ERR_JRET(
ctgMetaRentRemove(&pCtg->grantRent, msg->grantId, ctgGrantVersionSortCompare, ctgGrantVersionSearchCompare));
printf("prop:grant:0x%" PRIx64 "removed from rent", msg->grantId);
_return: _return:
@ -2557,7 +2560,6 @@ _return:
CTG_RET(code); CTG_RET(code);
} }
void ctgClearFreeCache(SCtgCacheOperation *operation) { void ctgClearFreeCache(SCtgCacheOperation *operation) {
SCtgClearCacheMsg *msg = operation->data; SCtgClearCacheMsg *msg = operation->data;
SCatalog *pCtg = msg->pCtg; SCatalog *pCtg = msg->pCtg;

View File

@ -301,11 +301,9 @@ int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t ctgUpdateRentGrantVersion(SCatalog *pCtg, int32_t grantId, int32_t ctgUpdateRentGrantVersion(SCatalog *pCtg, int32_t grantId, SCtgGrantCache *pCache) {
SCtgGrantCache *pCache) {
SGrantVersion metaRent = {.grantId = grantId, .version = pCache->grantInfo.version}; SGrantVersion metaRent = {.grantId = grantId, .version = pCache->grantInfo.version};
CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->grantRent, &metaRent, metaRent.grantId, sizeof(SGrantVersion), CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->grantRent, &metaRent, metaRent.grantId, sizeof(SGrantVersion),
ctgGrantVersionSortCompare, ctgGrantVersionSearchCompare)); ctgGrantVersionSortCompare, ctgGrantVersionSearchCompare));
@ -313,8 +311,3 @@ int32_t ctgUpdateRentGrantVersion(SCatalog *pCtg, int32_t grantId,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }