apache/cassandra · error · InvalidRequestException

Unknown keyspace: '" + keyspaceName + "'

Error message

Unknown keyspace: '" + keyspaceName + "'

What it means

The accord_debug.histo table's DataSet resolver maps a row's partition key to a keyspace name and requires a live keyspace instance. Schema.instance.getKeyspaceInstance() returns null for keyspaces that exist only in schema metadata (or not at all), and the resolver then throws InvalidRequestException with the unknown name.

Source

Thrown at src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java:895

                        ')', UTF8Type.instance));
        }

        @Override
        public DataSet data()
        {
            ConsensusMigrationState snapshot = ClusterMetadata.current().consensusMigrationState;
            Collection<TableMigrationState> tableStates = snapshot.tableStates();
            return data(tableStates);
        }

        @Override
        public DataSet data(DecoratedKey key)
        {
            String keyspaceName = UTF8Type.instance.compose(key.getKey());
            Keyspace keyspace = Schema.instance.getKeyspaceInstance(keyspaceName);

            if (keyspace == null)
                throw new InvalidRequestException("Unknown keyspace: '" + keyspaceName + '\'');

            List<TableId> tableIDs = keyspace.getColumnFamilyStores()
                                             .stream()
                                             .map(ColumnFamilyStore::getTableId)
                                             .collect(Collectors.toList());

            ConsensusMigrationState snapshot = ClusterMetadata.current().consensusMigrationState;
            Collection<TableMigrationState> tableStates = snapshot.tableStatesFor(tableIDs);

            return data(tableStates);
        }

        private SimpleDataSet data(Collection<TableMigrationState> tableStates)
        {
            SimpleDataSet result = new SimpleDataSet(metadata());

            for (TableMigrationState state : tableStates)
            {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Verify the keyspace name spelled in the partition key matches an existing, instantiated keyspace (check system_schema.keyspaces).
  2. Run the query on a node that has a live instance of the keyspace (i.e. holds replicas or has it opened).
  3. Recreate/re-open the keyspace if it was dropped and the debug rows are still needed.
  4. Ignore stale histo rows for dropped keyspaces rather than querying them.

Example fix

// before
session.execute("SELECT * FROM system_views.accord_debug_histo WHERE key = 'ks2'"); // ks2 dropped
// after
ResultSet check = session.execute("SELECT keyspace_name FROM system_schema.keyspaces WHERE keyspace_name = 'ks1'");
if (!check.isEmpty()) session.execute("SELECT * FROM system_views.accord_debug_histo WHERE key = 'ks1'");
Defensive patterns

Strategy: validation

Validate before calling

ResultSet rs = session.execute("SELECT keyspace_name FROM system_schema.keyspaces WHERE keyspace_name = ?", ks);
if (rs.isEmpty()) throw new IllegalArgumentException("Keyspace does not exist: " + ks);

Try / catch

try { session.execute(histoQuery); } catch (com.datastax.driver.core.exceptions.InvalidQueryException e) { if (e.getMessage().startsWith("Unknown keyspace")) { /* keyspace dropped or not instantiated; skip stale rows */ } else throw e; }

Prevention

When it happens

Trigger: Querying a histo row whose key names a keyspace that is dropped, not yet instantiated on this node, or misspelled; reading rows after the keyspace was dropped while stale rows are still addressable.

Common situations: Inspecting Accord histogram debug rows after dropping a keyspace; typo in keyspace name within the partition key; node that never opened the keyspace (e.g. it has no local replicas).

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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