apache/cassandra · error · InvalidRequestException

Table . does not exist

Error message

Table {keyspace}.{table} does not exist

What it means

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.

Solutions

  1. Retry with backoff; refresh schema if the table should exist (nodetool reload / schema agreement check)
  2. Correct the table name in client code or configuration
  3. If the drop was intentional, drain requests before executing DDL
  4. Check system_schema.tables on the node to confirm what schema it actually has
Defensive patterns

Strategy: try-catch

Validate before calling

KeyspaceMetadata ksm = session.getCluster().getMetadata().getKeyspace(keyspace);
if (ksm == null || ksm.getTable(table) == null)
    throw new IllegalArgumentException("Table " + keyspace + "." + table + " does not exist");

Try / catch

try { router.metadata(cm, keyspace, table, ...); }
catch (InvalidRequestException e) {
    // table dropped or name wrong: verify DDL intent, refresh schema, retry or abort
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/service/consensus/migration/ConsensusRequestRouter.java:179

    /*
     * Accord never handles local tables, but if the table doesn't exist then we need to generate the correct
     * InvalidRequestException.
     */
    private static TableMetadata metadata(ClusterMetadata cm, String keyspace, String table)
    {
        Optional<KeyspaceMetadata> ksm = cm.schema.maybeGetKeyspaceMetadata(keyspace);
        if (ksm.isEmpty())
        {
            // It's a non-distributed table which is fine, but we want to error if it doesn't exist
            // We should never actually reach here unless there is a race with dropping the table
            Keyspaces localKeyspaces = Schema.instance.localKeyspaces();
            KeyspaceMetadata ksm2 = localKeyspaces.getNullable(keyspace);
            if (ksm2 == null)
                throw new InvalidRequestException("Keyspace " + keyspace + " does not exist");
            // Explicitly including views in case they get used in non-distributed tables
            TableMetadata tbm2 = ksm2.getTableOrViewNullable(table);
            if (tbm2 == null)
                throw new InvalidRequestException("Table " + keyspace + "." + table + " does not exist");
            return null;
        }
        TableMetadata tbm = ksm.get().getTableNullable(table);
        if (tbm == null)
            throw new InvalidRequestException("Table " + keyspace + "." + table + " does not exist");

        return tbm;
    }

    public ConsensusRoutingDecision routeAndMaybeMigrate(@Nonnull ClusterMetadata cm, @Nonnull DecoratedKey key, @Nonnull TableId tableId, ConsistencyLevel consistencyLevel, Dispatcher.RequestTime requestTime, long timeoutNanos, boolean isForWrite)
    {
        TableMetadata metadata = getTableMetadata(cm, tableId);
        // Non-distributed tables always take the Paxos path
        if (metadata == null)
            return pickPaxos();
        return routeAndMaybeMigrate(cm, metadata, key, consistencyLevel, requestTime, timeoutNanos, isForWrite);
    }

View on GitHub (pinned to 88fd0f6a0e)