apache/cassandra · error · RuntimeException

Error occurred during garbage collection

Error message

Error occurred during garbage collection

What it means

GarbageCollect, for the explicit-keyspace path, wraps any exception from garbageCollect in a RuntimeException. It means the user-defined GC compaction for the specified keyspace/table failed server-side or the JMX invocation failed.

Solutions

  1. Read the 'Caused by' exception for the underlying error
  2. Verify keyspace/table names against cqlsh DESCRIBE output
  3. Ensure no conflicting repair/compaction is running (nodetool compactionstats, netstats)
  4. Retry with a valid tombstone option (row/cell) and modest -j value

Example fix

// before
nodetool garbagecollect wrongks
// after
cqlsh -e "DESCRIBE KEYSPACES" | grep wrongks || nodetool garbagecollect correctks
Defensive patterns

Strategy: try-catch

Validate before calling

cqlsh -e "DESCRIBE KEYSPACES" | grep -qw "$KS" || { echo 'unknown keyspace'; exit 1; }

Try / catch

try { probe.garbageCollect(out, opt, jobs, ks, tables); } catch (RuntimeException e) { handle(e.getCause()); }

Prevention

When it happens

Trigger: Running `nodetool garbagecollect [keyspace [tables...]]` with a nonexistent keyspace/table, invalid tombstone option, or when StorageService rejects the compaction (e.g. node busy, streaming in progress).

Common situations: Post-delete cleanup runs scripted per keyspace; typos in keyspace names in cron scripts; conflicts with ongoing major compactions or repairs.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/tools/nodetool/GarbageCollect.java:95

            }
            catch (Exception e)
            {
                throw new RuntimeException("Error occurred during user defined garbage collection", e);
            }
            return;
        }

        List<String> keyspaces = parseOptionalKeyspace(args, probe);
        String[] tableNames = parseOptionalTables(args);

        for (String keyspace : keyspaces)
        {
            try
            {
                probe.garbageCollect(probe.output().out, tombstoneOption.toString(), jobs, keyspace, tableNames);
            } catch (Exception e)
            {
                throw new RuntimeException("Error occurred during garbage collection", e);
            }
        }
    }
}

View on GitHub (pinned to 88fd0f6a0e)