mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fix changing a role which is already expired in RoleCache.
This commit is contained in:
parent
be043cd5a5
commit
9792b93a11
@ -163,11 +163,15 @@ void RoleCache::roleChanged(const UUID & role_id, const RolePtr & changed_role)
|
||||
|
||||
std::lock_guard lock{mutex};
|
||||
auto role_from_cache = cache.get(role_id);
|
||||
if (!role_from_cache)
|
||||
return;
|
||||
role_from_cache->first = changed_role;
|
||||
cache.update(role_id, role_from_cache);
|
||||
collectEnabledRoles(¬ifications);
|
||||
if (role_from_cache)
|
||||
{
|
||||
/// We update the role stored in a cache entry only if that entry has not expired yet.
|
||||
role_from_cache->first = changed_role;
|
||||
cache.update(role_id, role_from_cache);
|
||||
}
|
||||
|
||||
/// An enabled role for some users has been changed, we need to recalculate the access rights.
|
||||
collectEnabledRoles(¬ifications); /// collectEnabledRoles() must be called with the `mutex` locked.
|
||||
}
|
||||
|
||||
|
||||
@ -177,8 +181,12 @@ void RoleCache::roleRemoved(const UUID & role_id)
|
||||
scope_guard notifications;
|
||||
|
||||
std::lock_guard lock{mutex};
|
||||
|
||||
/// If a cache entry with the role has expired already, that remove() will do nothing.
|
||||
cache.remove(role_id);
|
||||
collectEnabledRoles(¬ifications);
|
||||
|
||||
/// An enabled role for some users has been removed, we need to recalculate the access rights.
|
||||
collectEnabledRoles(¬ifications); /// collectEnabledRoles() must be called with the `mutex` locked.
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user