mirror of https://github.com/apache/cassandra
Upgrade caffeine cache and fix CIDR permissions cache invalidation
patch by Ekaterina Dimitrova; reviewed by Jacek Lewandowski, Ben Manes, Yifan Cai, Shailaja Koppu for CASSANDRA-18805
This commit is contained in:
parent
d828cd0228
commit
eb30005251
|
|
@ -1015,7 +1015,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jctools</groupId>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
5.0-alpha2
|
||||
* Upgrade caffeine cache and fix CIDR permissions cache invalidation (CASSANDRA-18805)
|
||||
* Remove deprecated properties in CompressionParams (CASSANDRA-18742)
|
||||
* Add support for repair coordinator to retry messages that timeout (CASSANDRA-18816)
|
||||
* Upgrade slf4j-api to 1.7.36 (CASSANDRA-18882)
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ public class AuthCache<K, V> implements AuthCacheMBean, Shutdownable
|
|||
updatedCache = cache;
|
||||
// Always set as mandatory
|
||||
cache.policy().refreshAfterWrite().ifPresent(policy ->
|
||||
policy.setExpiresAfter(activeUpdate ? getValidity() : getUpdateInterval(), TimeUnit.MILLISECONDS));
|
||||
policy.setRefreshesAfter(activeUpdate ? getValidity() : getUpdateInterval(), TimeUnit.MILLISECONDS));
|
||||
cache.policy().expireAfterWrite().ifPresent(policy -> policy.setExpiresAfter(getValidity(), TimeUnit.MILLISECONDS));
|
||||
cache.policy().eviction().ifPresent(policy -> policy.setMaximum(getMaxEntries()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,11 @@ public class CIDRPermissionsCache extends AuthCache<RoleResource, CIDRPermission
|
|||
*/
|
||||
public boolean invalidateCidrPermissions(String roleName)
|
||||
{
|
||||
if (cache.getIfPresent(roleName) == null)
|
||||
RoleResource role = RoleResource.role(roleName);
|
||||
if (cache.getIfPresent(role) == null)
|
||||
return false;
|
||||
|
||||
invalidate(RoleResource.role(roleName));
|
||||
invalidate(role);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.codahale.metrics.Timer;
|
||||
import com.github.benmanes.caffeine.cache.RemovalCause;
|
||||
import com.github.benmanes.caffeine.cache.stats.CacheStats;
|
||||
import com.github.benmanes.caffeine.cache.stats.StatsCounter;
|
||||
import org.apache.cassandra.cache.ChunkCache;
|
||||
|
|
@ -72,7 +73,7 @@ public class ChunkCacheMetrics extends CacheMetrics implements StatsCounter
|
|||
}
|
||||
|
||||
@Override
|
||||
public void recordEviction()
|
||||
public void recordEviction(int weight, RemovalCause cause)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +81,6 @@ public class ChunkCacheMetrics extends CacheMetrics implements StatsCounter
|
|||
@Override
|
||||
public CacheStats snapshot()
|
||||
{
|
||||
return new CacheStats(hits.getCount(), misses.getCount(), missLatency.getCount(), 0L, missLatency.getCount(), 0L, 0L);
|
||||
return CacheStats.of(hits.getCount(), misses.getCount(), missLatency.getCount(), 0L, missLatency.getCount(), 0L, 0L);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.apache.cassandra.auth.AuthCacheService;
|
|||
import org.apache.cassandra.auth.AuthTestUtils;
|
||||
import org.apache.cassandra.auth.AuthenticatedUser;
|
||||
import org.apache.cassandra.auth.IRoleManager;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.tools.ToolRunner;
|
||||
|
|
@ -43,6 +44,7 @@ public class InvalidateCIDRPermissionsCacheTest extends CQLTester
|
|||
@BeforeClass
|
||||
public static void setup() throws Exception
|
||||
{
|
||||
DatabaseDescriptor.setRolesValidity(Integer.MAX_VALUE-1);
|
||||
CQLTester.setUpClass();
|
||||
CQLTester.requireAuthentication();
|
||||
|
||||
|
|
@ -122,6 +124,7 @@ public class InvalidateCIDRPermissionsCacheTest extends CQLTester
|
|||
// invalidate cidr permission
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeNodetool("invalidatecidrpermissionscache", ROLE_A.getRoleName());
|
||||
tool.assertOnCleanExit();
|
||||
assertThat(tool.getStdout()).contains("Invalidated the role role_a from CIDR permissions cache");
|
||||
|
||||
// ensure cidr permission is reloaded
|
||||
assertThat(role.hasAccessFromIp(new InetSocketAddress("127.0.0.0", 0))).isTrue();
|
||||
|
|
|
|||
Loading…
Reference in New Issue