enh: remove user cache when user dropped

This commit is contained in:
kailixu 2023-09-21 14:09:50 +08:00
parent 2ff0748022
commit eb6b6ec882
4 changed files with 36 additions and 31 deletions

View File

@ -104,8 +104,6 @@ static int32_t hbUpdateUserAuthInfo(SAppHbMgr *pAppHbMgr, SUserAuthBatchRsp *bat
}
}
releaseTscObj(pReq->connKey.tscRid);
// delete the tscObj
releaseTscObj(pReq->connKey.tscRid);
continue;
}
@ -579,6 +577,10 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
return TSDB_CODE_APP_ERROR;
}
// if(pTscObj->dropped == 1) {
// releaseTscObj(connKey->tscRid);
// }
int32_t code = 0;
SKv kv = {.key = HEARTBEAT_KEY_USER_AUTHINFO};

View File

@ -2241,13 +2241,10 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
goto _return;
}
int8_t userDropped = msg->userAuth.dropped;
SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, msg->userAuth.user, strlen(msg->userAuth.user));
if (NULL == pUser) {
if (userDropped) {
taosMemoryFreeClear(msg);
return TSDB_CODE_SUCCESS;
if (msg->userAuth.dropped == 1) {
goto _return;
}
SCtgUserAuth userAuth = {0};
@ -2265,8 +2262,10 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
CTG_CACHE_NUM_INC(CTG_CI_USER, 1);
return TSDB_CODE_SUCCESS;
} else if(userDropped) {
ctgRemoveCacheUser(pCtg, msg->userAuth.user);
} else if (msg->userAuth.dropped == 1) {
if (ctgRemoveCacheUser(pCtg, msg->userAuth.user) == 0) {
CTG_CACHE_NUM_DEC(CTG_CI_USER, 1);
}
goto _return;
}

View File

@ -317,10 +317,14 @@ int32_t ctgRemoveCacheUser(SCatalog* pCtg, const char* user) {
}
SCtgUserAuth* pUser = (SCtgUserAuth*)taosHashGet(pCtg->userCache, user, strlen(user));
if (pUser) {
ctgFreeSCtgUserAuth(pUser);
taosHashRemove(pCtg->userCache, user, strlen(user));
if (taosHashRemove(pCtg->userCache, user, strlen(user)) == 0) {
return 0; // user found and removed
}
}
return 0;
return -1;
}
void ctgFreeHandle(SCatalog* pCtg) {