apache/cassandra · warning · IllegalStateException

Unknown keyspace . This can occur if the keyspace is being…

Error message

Unknown keyspace %s. This can occur if the keyspace is being dropped.

What it means

SSTableIndexesSystemView.data() iterates user keyspaces and fetches live Keyspace instances; when a keyspace present in schema metadata has no live instance (typically being dropped concurrently), it throws IllegalStateException("Unknown keyspace %s. This can occur if the keyspace is being dropped.").

Solutions

  1. Retry the query after keyspace teardown finishes
  2. Serialize DROP KEYSPACE against virtual-table readers in tests/tools
  3. Upgrade to a version that tolerates in-flight schema changes

Example fix

null
Defensive patterns

Strategy: retry

Try / catch

try {
    rs = session.execute(queryVirtualTable);
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("Unknown keyspace")) {
        // keyspace being dropped; retry after backoff
    } else throw e;
}

Prevention

When it happens

Trigger: SELECT from the sstable_indexes virtual table while a keyspace is concurrently dropped; the metadata list still contains the keyspace but Schema.instance.getKeyspaceInstance returns null.

Common situations: Monitoring queries against system_views.sstable_indexes during schema churn; CI tests dropping keyspaces while observing index views.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/08e7858ecef647f4. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/index/sai/virtual/SSTableIndexesSystemView.java:91

                           .addRegularColumn(MIN_ROW_ID, LongType.instance)
                           .addRegularColumn(MAX_ROW_ID, LongType.instance)
                           .addRegularColumn(START_TOKEN, UTF8Type.instance)
                           .addRegularColumn(END_TOKEN, UTF8Type.instance)
                           .addRegularColumn(PER_TABLE_DISK_SIZE, LongType.instance)
                           .addRegularColumn(PER_COLUMN_DISK_SIZE, LongType.instance)
                           .build());
    }

    @Override
    public DataSet data()
    {
        SimpleDataSet dataset = new SimpleDataSet(metadata());

        for (KeyspaceMetadata ks : Schema.instance.getUserKeyspaces())
        {
            Keyspace keyspace = Schema.instance.getKeyspaceInstance(ks.name);
            if (keyspace == null)
                throw new IllegalStateException("Unknown keyspace " + ks + ". This can occur if the keyspace is being dropped.");

            for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores())
            {
                StorageAttachedIndexGroup group = StorageAttachedIndexGroup.getIndexGroup(cfs);

                if (group != null)
                {
                    Token.TokenFactory tokenFactory = cfs.metadata().partitioner.getTokenFactory();

                    group.getIndexes().forEach(i -> {
                        StorageAttachedIndex index = (StorageAttachedIndex)i;

                        for (SSTableIndex sstableIndex : index.view())
                        {
                            // Empty indexes are tracked internally for the sake of having complete views. However,
                            // these indexes have not historically been exposed in this virtual table, so we skip
                            // them for now.
                            if (sstableIndex.getRowCount() == 0)

View on GitHub (pinned to 88fd0f6a0e)