{"record":{"id":"b869c97298742289","repo":"apache/cassandra","slug":"table-keyspace-table-does-not-exist","errorCode":null,"errorMessage":"Table {keyspace}.{table} does not exist","messagePattern":"Table (.+?)\\.(.+?) does not exist","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/consensus/migration/ConsensusRequestRouter.java","lineNumber":179,"sourceCode":"    /*\n     * Accord never handles local tables, but if the table doesn't exist then we need to generate the correct\n     * InvalidRequestException.\n     */\n    private static TableMetadata metadata(ClusterMetadata cm, String keyspace, String table)\n    {\n        Optional<KeyspaceMetadata> ksm = cm.schema.maybeGetKeyspaceMetadata(keyspace);\n        if (ksm.isEmpty())\n        {\n            // It's a non-distributed table which is fine, but we want to error if it doesn't exist\n            // We should never actually reach here unless there is a race with dropping the table\n            Keyspaces localKeyspaces = Schema.instance.localKeyspaces();\n            KeyspaceMetadata ksm2 = localKeyspaces.getNullable(keyspace);\n            if (ksm2 == null)\n                throw new InvalidRequestException(\"Keyspace \" + keyspace + \" does not exist\");\n            // Explicitly including views in case they get used in non-distributed tables\n            TableMetadata tbm2 = ksm2.getTableOrViewNullable(table);\n            if (tbm2 == null)\n                throw new InvalidRequestException(\"Table \" + keyspace + \".\" + table + \" does not exist\");\n            return null;\n        }\n        TableMetadata tbm = ksm.get().getTableNullable(table);\n        if (tbm == null)\n            throw new InvalidRequestException(\"Table \" + keyspace + \".\" + table + \" does not exist\");\n\n        return tbm;\n    }\n\n    public ConsensusRoutingDecision routeAndMaybeMigrate(@Nonnull ClusterMetadata cm, @Nonnull DecoratedKey key, @Nonnull TableId tableId, ConsistencyLevel consistencyLevel, Dispatcher.RequestTime requestTime, long timeoutNanos, boolean isForWrite)\n    {\n        TableMetadata metadata = getTableMetadata(cm, tableId);\n        // Non-distributed tables always take the Paxos path\n        if (metadata == null)\n            return pickPaxos();\n        return routeAndMaybeMigrate(cm, metadata, key, consistencyLevel, requestTime, timeoutNanos, isForWrite);\n    }\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/consensus/migration/ConsensusRequestRouter.java#L161-L197","documentation":"ConsensusRequestRouter.metadata() looks up the table (or view) within a resolved keyspace and throws InvalidRequestException if it is missing. This covers both the distributed-schema path (ksm.get().getTableNullable) and is normally hit only when a DROP TABLE races with in-flight requests.","triggerScenarios":"A request targeting keyspace.table where the table/view does not exist in the current schema — DROP TABLE racing in-flight requests, stale schema on the routing node, or a client referencing a removed table.","commonSituations":"Concurrent DROP TABLE with live traffic; application config pointing at a renamed/dropped table; schema disagreement where one node has not yet applied the drop (or has applied it early).","solutions":["Retry with backoff; refresh schema if the table should exist (nodetool reload / schema agreement check)","Correct the table name in client code or configuration","If the drop was intentional, drain requests before executing DDL","Check system_schema.tables on the node to confirm what schema it actually has"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"KeyspaceMetadata ksm = session.getCluster().getMetadata().getKeyspace(keyspace);\nif (ksm == null || ksm.getTable(table) == null)\n    throw new IllegalArgumentException(\"Table \" + keyspace + \".\" + table + \" does not exist\");","typeGuard":null,"tryCatchPattern":"try { router.metadata(cm, keyspace, table, ...); }\ncatch (InvalidRequestException e) {\n    // table dropped or name wrong: verify DDL intent, refresh schema, retry or abort\n}","preventionTips":["Verify schema agreement after DDL before resuming traffic","Validate table names in app config at startup","Serialize DDL with application deployments"],"tags":["schema","invalid-request","race-condition"],"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-17T15:17:12.973Z"}