apache/cassandra · error · RuntimeException

Table {tableName} does not exist in keyspace {keyspace}

Error message

Table {tableName} does not exist in keyspace {keyspace}

What it means

Thrown by StorageService's unrepaired-SSTable listing API when one of the requested table names does not exist in the given keyspace. A plain RuntimeException that validates the tableNames list against the keyspace's live ColumnFamilyStores before mutating any SSTables.

Source

Thrown at src/java/org/apache/cassandra/service/StorageService.java:5887

    {
        return Keyspace.open(keyspace).getColumnFamilyStores().stream().map(cfs -> cfs.name).collect(Collectors.toList());
    }

    @Override
    public void validateAndRepairPeersMetadata()
    {
        SystemPeersValidator.validateAndRepair(ClusterMetadata.current());
    }

    @Override
    public List<String> mutateSSTableRepairedState(boolean repaired, boolean preview, String keyspace, List<String> tableNames)
    {
        Map<String, ColumnFamilyStore> tables =  Keyspace.open(keyspace).getColumnFamilyStores()
                                                         .stream().collect(Collectors.toMap(c -> c.name, c -> c));
        for (String tableName : tableNames)
        {
            if (!tables.containsKey(tableName))
                throw new RuntimeException("Table " + tableName + " does not exist in keyspace " + keyspace);
        }

        // only select SSTables that are unrepaired when repaired is true and vice versa
        Predicate<SSTableReader> predicate = sst -> repaired != sst.isRepaired();

        // mutate SSTables
        long repairedAt = !repaired ? 0 : currentTimeMillis();
        List<String> sstablesTouched = new ArrayList<>();
        for (String tableName : tableNames)
        {
            ColumnFamilyStore table = tables.get(tableName);
            Set<SSTableReader> result = table.runWithCompactionsDisabled(() -> {
                Set<SSTableReader> sstables = table.getLiveSSTables().stream().filter(predicate).collect(Collectors.toSet());
                if (!preview)
                    table.getCompactionStrategyManager().mutateRepaired(sstables, repairedAt, null, false);
                return sstables;
            }, predicate, OperationType.ANTICOMPACTION, true, false, true);
            if (result == null)

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Validate each name against system_schema.tables for the keyspace and correct typos.
  2. Remove entries for tables that no longer exist.
  3. Pass bare table names, not keyspace-qualified names.

Example fix

// before
List<String> names = Arrays.asList("t1", "ks.t2");
ss.unrepairedSSTables("ks", names); // throws for 'ks.t2'
// after
List<String> names = Arrays.asList("t1", "t2");
ss.unrepairedSSTables("ks", names);
Defensive patterns

Strategy: validation

Validate before calling

Set<String> existing = Schema.instance.getKeyspaceMetadata(keyspace).tables.stream().map(t -> t.name).collect(Collectors.toSet());
List<String> invalid = tableNames.stream().filter(n -> !existing.contains(n)).collect(Collectors.toList());
if (!invalid.isEmpty()) throw new IllegalArgumentException("unknown tables: " + invalid);

Try / catch

try { ss.unrepairedSSTables(keyspace, tableNames); }
catch (RuntimeException e) { if (e.getMessage().contains("does not exist in keyspace")) { /* fix name list */ } throw e; }

Prevention

When it happens

Trigger: Calling the SSTable repair/anticompaction listing method (e.g. unrepairedSSTables / scrub-style JMX ops) with a tableNames entry absent from Keyspace.open(keyspace).getColumnFamilyStores().

Common situations: Typo in a table name in a multi-table list; table dropped mid-operation; using fully qualified names (ks.tbl) where only bare table names are expected.

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/f8e2a3653ecbcdaf. Report an issue: GitHub.