{"record":{"id":"2b87d9dd3ad84dd7","repo":"apache/cassandra","slug":"unknown-keyspace-s","errorCode":null,"errorMessage":"Unknown keyspace %s","messagePattern":"Unknown keyspace (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/index/sai/virtual/ColumnIndexesSystemView.java","lineNumber":85,"sourceCode":"                           .build());\n    }\n\n    @Override\n    public void apply(PartitionUpdate update)\n    {\n        throw new InvalidRequestException(\"Modification is not supported by table \" + metadata);\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 IllegalArgumentException(\"Unknown keyspace \" + ks.name);\n\n            for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores())\n            {\n                SecondaryIndexManager manager = cfs.indexManager;\n                StorageAttachedIndexGroup group = StorageAttachedIndexGroup.getIndexGroup(cfs);\n\n                if (group != null)\n                {\n                    group.getIndexes().forEach(i -> {\n                        StorageAttachedIndex index = (StorageAttachedIndex) i;\n                        String indexName = index.identifier().indexName;\n\n                        dataset.row(ks.name, indexName)\n                               .column(TABLE_NAME, cfs.name)\n                               .column(COLUMN_NAME, index.termType().columnName())\n                               .column(IS_QUERYABLE, manager.isIndexQueryable(index))\n                               .column(IS_BUILDING, manager.isIndexBuilding(indexName))\n                               .column(IS_STRING, index.termType().isLiteral())","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sai/virtual/ColumnIndexesSystemView.java#L67-L103","documentation":"ColumnIndexesSystemView.data() iterates user keyspaces from Schema metadata and then fetches the live Keyspace instance. If a keyspace exists in metadata but has no live instance (dropped concurrently), getKeyspaceInstance returns null and data() throws IllegalArgumentException(\"Unknown keyspace ...\"). This is a race between schema iteration and keyspace teardown.","triggerScenarios":"Querying the column_indexes virtual table while a keyspace is being dropped concurrently — Schema.instance.getUserKeyspaces() lists the keyspace, but its instance is gone by the time getKeyspaceInstance runs.","commonSituations":"Monitoring dashboards polling virtual tables during DROP KEYSPACE; test suites dropping schemas while another client reads virtual tables.","solutions":["Retry the virtual-table query after the DROP completes","Avoid querying system_views.column_indexes concurrently with keyspace drops","Upgrade — newer versions skip such keyspaces instead of throwing"],"exampleFix":"null","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for (int i = 0; i < 3; i++) {\n    try { rs = session.execute(queryVirtualTable); break; }\n    catch (IllegalArgumentException e) {\n        if (e.getMessage().startsWith(\"Unknown keyspace\")) { sleep(backoff); continue; }\n        throw e;\n    }\n}","preventionTips":["Avoid polling virtual tables during DROP KEYSPACE","Serialize schema changes against monitoring reads in tests","Treat transient 'Unknown keyspace' on views as retryable"],"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"}