nodetool invalidatepermissionscache
Invalidates the permissions cache on the node.
Synopsis
Section titled “Synopsis”nodetool [connection_options] invalidatepermissionscacheSee connection options for connection options.
Description
Section titled “Description”nodetool invalidatepermissionscache clears all cached permission entries on the node. The permissions cache stores authorization information, allowing Cassandra to avoid querying the system_auth.role_permissions table for every operation.
After invalidation, subsequent operations trigger fresh permission lookups from the system tables, which are then re-cached.
Authentication Required
The permissions cache is only relevant when authentication and authorization are enabled. If running with default settings (no auth), this cache is not used.
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”nodetool invalidatepermissionscacheAfter Permission Changes
Section titled “After Permission Changes”# After GRANT or REVOKE operationsnodetool invalidatepermissionscachePermissions Cache Overview
Section titled “Permissions Cache Overview”What the Cache Stores
Section titled “What the Cache Stores”| Cached Data | Description |
|---|---|
| Role | The authenticated role/user |
| Resource | The protected resource (keyspace, table) |
| Permissions | Granted permissions (SELECT, MODIFY, etc.) |
How It Improves Performance
Section titled “How It Improves Performance”Without Permissions Cache: Every Operation → Query system_auth.role_permissions → Check permission → Execute
With Permissions Cache: Operation → Check cached permission → Execute (Avoids repeated auth table queries)Permission Types
Section titled “Permission Types”| Permission | Operations |
|---|---|
| SELECT | Read data |
| MODIFY | Write data (INSERT, UPDATE, DELETE) |
| CREATE | Create resources |
| ALTER | Modify resources |
| DROP | Delete resources |
| AUTHORIZE | Grant/revoke permissions |
When to Use
Section titled “When to Use”After Permission Changes
Section titled “After Permission Changes”When GRANT or REVOKE statements don't immediately take effect:
# Permission changecqlsh -e "GRANT SELECT ON my_keyspace.my_table TO analyst_role;"
# If permission not immediately effectivenodetool invalidatepermissionscacheDuring Security Incident Response
Section titled “During Security Incident Response”When immediate permission revocation is critical:
# Revoke access immediatelycqlsh -e "REVOKE ALL ON ALL KEYSPACES FROM compromised_user;"
# Force cache refresh on all nodesfor node in $(nodetool status | grep "^UN" | awk '{print $2}'); do ssh "$node" "nodetool invalidatepermissionscache"doneAfter Role Modifications
Section titled “After Role Modifications”When role hierarchies change:
# After modifying role membershipcqlsh -e "REVOKE admin_role FROM former_admin;"
# Invalidate to ensure changes take effectnodetool invalidatepermissionscacheTroubleshooting Access Issues
Section titled “Troubleshooting Access Issues”When permissions appear incorrect:
# Clear potentially stale permissionsnodetool invalidatepermissionscache
# Retry operationImpact Assessment
Section titled “Impact Assessment”Immediate Effects
Section titled “Immediate Effects”| Aspect | Impact |
|---|---|
| Cached permissions | All cleared |
| Next operations | Require auth table lookups |
| Operation latency | Slight increase until cache warms |
Security Effects
Section titled “Security Effects”| Scenario | Behavior |
|---|---|
| Permission revocation | Takes effect immediately |
| New grants | Available immediately |
| Role changes | Reflected immediately |
Configuration
Section titled “Configuration”Cache Settings
Section titled “Cache Settings”The cassandra.yaml parameter names vary by version:
| Cassandra Version | Validity Parameter | Update Interval Parameter |
|---|---|---|
| Pre-4.1 | permissions_validity_in_ms | permissions_update_interval_in_ms |
| 4.1+ | permissions_validity | permissions_update_interval |
# cassandra.yaml (4.1+)permissions_validity: 2spermissions_update_interval: 1spermissions_cache_max_entries: 1000
# cassandra.yaml (Pre-4.1)# permissions_validity_in_ms: 2000# permissions_update_interval_in_ms: 1000# permissions_cache_max_entries: 1000Automatic Refresh
Section titled “Automatic Refresh”Permissions are automatically refreshed based on permissions_validity. Invalidation forces immediate refresh.
Cluster-Wide Operations
Section titled “Cluster-Wide Operations”Invalidate on All Nodes
Section titled “Invalidate on All Nodes”For permission changes to take effect cluster-wide immediately:
#!/bin/bashecho "Invalidating permissions cache cluster-wide..."
# Get list of node IPs from local nodetool statusnodes=$(nodetool status | grep "^UN" | awk '{print $2}')
for node in $nodes; do echo -n "$node: " ssh "$node" 'nodetool invalidatepermissionscache 2>/dev/null && echo "invalidated" || echo "FAILED"'done
echo "Permissions cache cleared on all nodes."Security Emergency Response
Section titled “Security Emergency Response”#!/bin/bashUSER_TO_REVOKE="$1"
if [ -z "$USER_TO_REVOKE" ]; then echo "Usage: $0 <username>" exit 1fi
echo "=== Emergency Permission Revocation ==="echo "Revoking all permissions for: $USER_TO_REVOKE"
# 1. Revoke permissionscqlsh -e "REVOKE ALL PERMISSIONS ON ALL KEYSPACES FROM $USER_TO_REVOKE;"
# 2. Invalidate cache on all nodes# Get list of node IPs from local nodetool statusnodes=$(nodetool status | grep "^UN" | awk '{print $2}')for node in $nodes; do ssh "$node" "nodetool invalidatepermissionscache 2>/dev/null"done
echo "Permissions revoked and cache cleared."Workflow: Permission Change with Validation
Section titled “Workflow: Permission Change with Validation”#!/bin/bashROLE="$1"RESOURCE="$2"PERMISSION="$3"
echo "=== Permission Change Workflow ==="
# 1. Show current permissionsecho "1. Current permissions for $ROLE:"cqlsh -e "LIST ALL PERMISSIONS OF $ROLE;"
# 2. Make changeecho ""echo "2. Granting $PERMISSION on $RESOURCE to $ROLE..."cqlsh -e "GRANT $PERMISSION ON $RESOURCE TO $ROLE;"
# 3. Invalidate cacheecho ""echo "3. Invalidating permissions cache..."nodetool invalidatepermissionscache
# 4. Verify changeecho ""echo "4. Permissions after change:"cqlsh -e "LIST ALL PERMISSIONS OF $ROLE;"
echo ""echo "=== Complete ==="Troubleshooting
Section titled “Troubleshooting”Permission Changes Not Taking Effect
Section titled “Permission Changes Not Taking Effect”# Invalidate on the specific node handling the requestnodetool invalidatepermissionscache
# Or invalidate cluster-widefor node in $(nodetool status | grep "^UN" | awk '{print $2}'); do ssh "$node" "nodetool invalidatepermissionscache"doneAuthentication Errors After Invalidation
Section titled “Authentication Errors After Invalidation”# Check system_auth tables are accessiblecqlsh -e "SELECT * FROM system_auth.roles LIMIT 1;"
# Check for auth-related errors in logsgrep -i "auth\|permission" /var/log/cassandra/system.log | tail -20High Latency After Invalidation
Section titled “High Latency After Invalidation”# Temporary increase in auth lookups is expected# Cache will warm up quickly with normal operations
# Monitor auth-related metricsnodetool tpstats | grep -i authBest Practices
Section titled “Best Practices”Permissions Cache Guidelines
- Invalidate after critical changes - Don't wait for cache expiry for security-sensitive changes
- Cluster-wide for security - Always invalidate all nodes when revoking access
- Test permission changes - Verify changes took effect
- Document procedures - Have runbooks for permission-related incidents
- Monitor auth performance - Watch for auth-related latency
Security Considerations
- Always invalidate cluster-wide when revoking permissions
- Consider the cache validity period for security-sensitive environments
- Shorter
permissions_validity= more responsive but higher overhead - Log all permission changes for audit purposes
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| invalidatecredentialscache | Invalidate credentials cache |
| invalidaterolescache | Invalidate roles cache |
| invalidatenetworkpermissionscache | Invalidate network permissions |