{"record":{"id":"24532f2128ada68f","repo":"apache/cassandra","slug":"unknown-cf-s-s","errorCode":null,"errorMessage":"Unknown CF %s %s","messagePattern":"Unknown CF (.+?) (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/Keyspace.java","lineNumber":213,"sourceCode":"\n    public Collection<ColumnFamilyStore> getColumnFamilyStores()\n    {\n        return Collections.unmodifiableCollection(columnFamilyStores.values());\n    }\n\n    public ColumnFamilyStore getColumnFamilyStore(String cfName)\n    {\n        TableMetadata table = schema.getTableMetadata(getName(), cfName);\n        if (table == null)\n            throw new IllegalArgumentException(String.format(\"Unknown keyspace/cf pair (%s.%s)\", getName(), cfName));\n        return getColumnFamilyStore(table.id);\n    }\n\n    public ColumnFamilyStore getColumnFamilyStore(TableId id)\n    {\n        ColumnFamilyStore cfs = columnFamilyStores.get(id);\n        if (cfs == null)\n            throw new IllegalArgumentException(String.format(\"Unknown CF %s %s\", id, columnFamilyStores));\n        return cfs;\n    }\n\n    public ColumnFamilyStore getIfExists(TableId id)\n    {\n        return columnFamilyStores.get(id);\n    }\n\n    public boolean hasColumnFamilyStore(TableId id)\n    {\n        return columnFamilyStores.containsKey(id);\n    }\n\n    public static void verifyKeyspaceIsValid(String keyspaceName)\n    {\n        if (null != VirtualKeyspaceRegistry.instance.getKeyspaceNullable(keyspaceName))\n            throw new IllegalArgumentException(\"Cannot perform any operations against virtual keyspace \" + keyspaceName);\n","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/Keyspace.java#L195-L231","documentation":"Keyspace.getColumnFamilyStore(TableId) looks up the ColumnFamilyStore in this keyspace's in-memory map by TableId. If absent it throws IllegalArgumentException 'Unknown CF <id> <stores>'. Unlike the name-based lookup this uses the live columnFamilyStores registry, so it usually indicates a stale TableId after a drop/recreate or an id from another keyspace.","triggerScenarios":"Passing a TableId obtained from schema metadata/sstables/compaction history that no longer matches a live store (table dropped and recreated gets a new id); id belonging to a different keyspace; race between a DROP TABLE and in-flight operations (compaction, streaming, repair) holding the old id.","commonSituations":"Restored sstables or compaction logs referencing a pre-drop table id; schema disagreement across nodes after concurrent DROP/CREATE; code caching TableId across deployments; attempts to route reads/writes to a just-dropped table.","solutions":["Re-resolve the store by name instead of a cached id: Schema.instance.getTableMetadata(ks, table) then keyspace.getColumnFamilyStore(TableMetadata.id).","Run `nodetool reload schema` and ensure schema agreement on all nodes if drop/recreate races occurred.","Restore the table (CREATE TABLE) if operations must target it, or discard the stale work (orphaned sstables/compaction tasks) for the dropped id.","Update cached TableIds in tooling after any schema change."],"exampleFix":"// before: cached id may be stale\ncfs = keyspace.getColumnFamilyStore(cachedId);\n// after: re-resolve by name\ntable = Schema.instance.getTableMetadata(keyspace.getName(), \"my_table\");\nif (table != null) cfs = keyspace.getColumnFamilyStore(table.id);","handlingStrategy":"type-guard","validationCode":"TableMetadata tm = Schema.instance.getTableMetadata(ks, table);\nif (tm == null) throw new IllegalStateException(\"table missing\");\n// use tm.id immediately; do not cache across schema changes\n","typeGuard":"static boolean hasCf(Keyspace ks, TableId id) {\n    return ks.getColumnFamilyStores().stream().anyMatch(c -> c.getTableId().equals(id));\n}\n","tryCatchPattern":"try {\n    return keyspace.getColumnFamilyStore(tableId);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unknown CF\")) {\n        Schema.instance.reloadSchema();\n        return keyspace.getIfExists(tableId); // null-safe fallback\n    }\n    throw e;\n}\n","preventionTips":["Never cache TableId long-term; re-fetch TableMetadata before use.","Wait for schema agreement after DROP/CREATE TABLE before issuing dependent operations.","Use getIfExists(TableId) when the table may legitimately be gone."],"tags":["schema","table-not-found","tableid","stale-metadata"],"backgroundTag":"entity-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}