{"record":{"id":"08e7858ecef647f4","repo":"apache/cassandra","slug":"unknown-keyspace-s-this-can-occur-if-the-keyspac","errorCode":null,"errorMessage":"Unknown keyspace %s. This can occur if the keyspace is being dropped.","messagePattern":"Unknown keyspace (.+?)\\. This can occur if the keyspace is being dropped\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/index/sai/virtual/SSTableIndexesSystemView.java","lineNumber":91,"sourceCode":"                           .addRegularColumn(MIN_ROW_ID, LongType.instance)\n                           .addRegularColumn(MAX_ROW_ID, LongType.instance)\n                           .addRegularColumn(START_TOKEN, UTF8Type.instance)\n                           .addRegularColumn(END_TOKEN, UTF8Type.instance)\n                           .addRegularColumn(PER_TABLE_DISK_SIZE, LongType.instance)\n                           .addRegularColumn(PER_COLUMN_DISK_SIZE, LongType.instance)\n                           .build());\n    }\n\n    @Override\n    public DataSet data()\n    {\n        SimpleDataSet dataset = new SimpleDataSet(metadata());\n\n        for (KeyspaceMetadata ks : Schema.instance.getUserKeyspaces())\n        {\n            Keyspace keyspace = Schema.instance.getKeyspaceInstance(ks.name);\n            if (keyspace == null)\n                throw new IllegalStateException(\"Unknown keyspace \" + ks + \". This can occur if the keyspace is being dropped.\");\n\n            for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores())\n            {\n                StorageAttachedIndexGroup group = StorageAttachedIndexGroup.getIndexGroup(cfs);\n\n                if (group != null)\n                {\n                    Token.TokenFactory tokenFactory = cfs.metadata().partitioner.getTokenFactory();\n\n                    group.getIndexes().forEach(i -> {\n                        StorageAttachedIndex index = (StorageAttachedIndex)i;\n\n                        for (SSTableIndex sstableIndex : index.view())\n                        {\n                            // Empty indexes are tracked internally for the sake of having complete views. However,\n                            // these indexes have not historically been exposed in this virtual table, so we skip\n                            // them for now.\n                            if (sstableIndex.getRowCount() == 0)","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sai/virtual/SSTableIndexesSystemView.java#L73-L109","documentation":"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.\").","triggerScenarios":"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.","commonSituations":"Monitoring queries against system_views.sstable_indexes during schema churn; CI tests dropping keyspaces while observing index views.","solutions":["Retry the query after keyspace teardown finishes","Serialize DROP KEYSPACE against virtual-table readers in tests/tools","Upgrade to a version that tolerates in-flight schema changes"],"exampleFix":"null","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    rs = session.execute(queryVirtualTable);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Unknown keyspace\")) {\n        // keyspace being dropped; retry after backoff\n    } else throw e;\n}","preventionTips":["Don't query sstable_indexes concurrently with schema drops","Add backoff-retry wrappers around virtual-table reads in monitoring code","Schedule schema mutations outside monitoring windows"],"tags":["sai","virtual-table","race-condition","schema"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}