apache/cassandra · warning
Failed to disconnect invalid roles
Error message
Failed to disconnect invalid roles
What it means
CassandraRoleManager's periodic invalidRoleDisconnectTask logs 'Failed to disconnect invalid roles' at WARN when disconnecting sessions of roles whose metadata failed validation throws. The task is non-fatal: it reschedules itself after nextDelayMillis.
Solutions
- Check the attached stack trace to see why disconnection failed (usually a secondary exception, not the role metadata itself).
- Fix the underlying invalid role rows (see error 2774 solutions) so fewer sessions need forced disconnection.
- Verify ClientState/connection registry health; restart the node if session tracking is wedged.
- The task auto-retries — after fixing root cause, confirm the warning stops appearing in logs.
Defensive patterns
Strategy: try-catch
Validate before calling
-- find and fix invalid role rows so disconnection succeeds SELECT role, can_login, is_superuser FROM system_auth.roles WHERE can_login = null ALLOW FILTERING;
Try / catch
try {
disconnectInvalidRoles();
} catch (Exception e) {
logger.warn("Failed to disconnect invalid roles", e); // inspect cause, task reschedules anyway
} Prevention
- Fix invalid role rows promptly — they also degrade the disconnection task.
- Watch logs for repeated warnings; persistent failure points to session-registry issues.
- Restart the node if the invalid-role task appears wedged.
When it happens
Trigger: Background task disconnectInvalidRoles() throws while iterating active client sessions whose authenticated role has invalid metadata (e.g. rows like error 2774) — failures in the session/connection registry or auth lookup.
Common situations: Clusters with corrupted system_auth role rows where enforcement of invalid-role disconnection repeatedly fails; concurrent client churn causing race conditions while iterating sessions.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Can not add identity for non-existent role
- Invalid metadata has been detected for role
- Invalid value for property
- Invalid value for property
- Only superusers are allowed to alter superuser status
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/8d72f8271a59f6d4.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/auth/CassandraRoleManager.java:805
return entries;
};
}
protected void disconnectInvalidRoles()
{
// This should always run with jitter, otherwise there's a risk that all nodes disconnect clients at the same time
StorageService.instance.disconnectInvalidRoles();
}
protected void invalidRoleDisconnectTask(LongSupplier delayMillis, ScheduledExecutorService executor)
{
try
{
disconnectInvalidRoles();
}
catch (Exception e)
{
logger.warn("Failed to disconnect invalid roles", e);
}
long nextDelayMillis = delayMillis.getAsLong();
logger.info("Scheduling next invalid role disconnection in {} millis", nextDelayMillis);
this.invalidRoleDisconnectTask = executor.schedule(() -> invalidRoleDisconnectTask(delayMillis, executor), nextDelayMillis, TimeUnit.MILLISECONDS);
}
protected void scheduleDisconnectInvalidRoleTask()
{
// Cancel any pending execution if it exists, since we may have changed period / jitter parameters
if (this.invalidRoleDisconnectTask != null)
{
logger.debug("Canceling previous invalidRoleDisconnectTask");
this.invalidRoleDisconnectTask.cancel(true);
}
long period = getInvalidClientDisconnectPeriodMillis();
long jitter = getInvalidClientDisconnectMaxJitterMillis();View on GitHub (pinned to 88fd0f6a0e)