diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index ba59ab85e9..914ecb64ff 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -146,7 +146,7 @@ typedef struct SSTableVersion { } SSTableVersion; typedef struct SGrantVersion { - int32_t grantId; + int64_t grantId; int32_t version; } SGrantVersion; diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index d86825c216..4d759d6bd7 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -568,6 +568,7 @@ typedef struct SCtgUpdateGrantInfoMsg { typedef struct SCtgDropGrantInfoMsg { SCatalog* pCtg; + int64_t grantId; } SCtgDropGrantInfoMsg; typedef struct SCtgCacheOperation { @@ -1040,10 +1041,12 @@ 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); diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 800e1edb80..0f93ba317a 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -1739,7 +1739,7 @@ int32_t ctgWriteGrantInfoToCache(SCatalog *pCtg, SGrantHbRsp *pRsp) { pCache->grantInfo = *pRsp; 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)); @@ -2540,15 +2540,18 @@ _return: } int32_t ctgOpDropGrantInfo(SCtgCacheOperation *operation) { - int32_t code = 0; + int32_t code = 0; SCtgDropGrantInfoMsg *msg = operation->data; - SCatalog *pCtg = msg->pCtg; + SCatalog *pCtg = msg->pCtg; if (pCtg->stopUpdate) { 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: @@ -2557,7 +2560,6 @@ _return: CTG_RET(code); } - void ctgClearFreeCache(SCtgCacheOperation *operation) { SCtgClearCacheMsg *msg = operation->data; SCatalog *pCtg = msg->pCtg; diff --git a/source/libs/catalog/src/ctgRent.c b/source/libs/catalog/src/ctgRent.c index 799c76d5e5..9ef1cf5928 100755 --- a/source/libs/catalog/src/ctgRent.c +++ b/source/libs/catalog/src/ctgRent.c @@ -301,11 +301,9 @@ int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName, return TSDB_CODE_SUCCESS; } -int32_t ctgUpdateRentGrantVersion(SCatalog *pCtg, int32_t grantId, - SCtgGrantCache *pCache) { +int32_t ctgUpdateRentGrantVersion(SCatalog *pCtg, int32_t grantId, SCtgGrantCache *pCache) { SGrantVersion metaRent = {.grantId = grantId, .version = pCache->grantInfo.version}; - CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->grantRent, &metaRent, metaRent.grantId, sizeof(SGrantVersion), ctgGrantVersionSortCompare, ctgGrantVersionSearchCompare)); @@ -313,8 +311,3 @@ int32_t ctgUpdateRentGrantVersion(SCatalog *pCtg, int32_t grantId, return TSDB_CODE_SUCCESS; } - - - - -