apache/cassandra · error · RuntimeException
Cannot remove temporary or obsoleted files for %s.%s due to
Error message
Cannot remove temporary or obsoleted files for %s.%s due to a problem with transaction log files.
What it means
Like SSTableLevelResetter, SSTableOfflineRelevel cleans unfinished LifecycleTransaction leftovers before releveling. Failure of removeUnfinishedLeftovers(cfs) — typically corrupt or inconsistent transaction log files — raises this RuntimeException identifying the keyspace and table.
Source
Thrown at src/java/org/apache/cassandra/tools/SSTableOfflineRelevel.java:107
}
Util.initDatabaseDescriptor();
ClusterMetadataService.initializeForTools(false);
boolean dryRun = args[0].equals("--dry-run");
String keyspace = args[args.length - 2];
String columnfamily = args[args.length - 1];
if (Schema.instance.getTableMetadata(keyspace, columnfamily) == null)
throw new IllegalArgumentException(String.format("Unknown keyspace/table %s.%s",
keyspace,
columnfamily));
// remove any leftovers in the transaction log
Keyspace ks = Keyspace.openWithoutSSTables(keyspace);
ColumnFamilyStore cfs = ks.getColumnFamilyStore(columnfamily);
if (!LifecycleTransaction.removeUnfinishedLeftovers(cfs))
{
throw new RuntimeException(String.format("Cannot remove temporary or obsoleted files for %s.%s " +
"due to a problem with transaction log files.",
keyspace, columnfamily));
}
Directories.SSTableLister lister = cfs.getDirectories().sstableLister(Directories.OnTxnErr.THROW).skipTemporary(true);
SetMultimap<File, SSTableReader> sstableMultimap = HashMultimap.create();
for (Map.Entry<Descriptor, Set<Component>> sstable : lister.list().entrySet())
{
if (sstable.getKey() != null)
{
try
{
SSTableReader reader = SSTableReader.open(cfs, sstable.getKey());
sstableMultimap.put(reader.descriptor.directory, reader);
}
catch (Throwable t)
{
out.println("Couldn't open sstable: "+sstable.getKey().fileFor(Components.DATA));View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Restore referenced-but-missing SSTables from a replica/backup or remove orphaned txn logs after verification
- Re-run sstableofflinerelevel once the table directory is consistent
- Check *txn.log files in the table directory for dangling references
- Back up the directory before manual cleanup
Defensive patterns
Strategy: validation
Validate before calling
// check for dangling txn logs in the table directory before releveling
if (java.util.Arrays.stream(tableDir.toFile().listFiles()).anyMatch(f -> f.getName().endsWith(".txn.log")))
LOG.warn("txn logs present; ensure leftover cleanup will succeed before releveling"); Try / catch
try { SSTableOfflineRelevel.main(args); }
catch (RuntimeException e) { LOG.error("leftover cleanup failed: " + e.getMessage(), e); } Prevention
- Run offline tools only on cleanly stopped nodes or consistent snapshots
- Restore missing SSTables referenced by txn logs before releveling
- Keep a backup of the table directory
When it happens
Trigger: Running `sstableofflinerelevel` on a table with corrupted, partially-written, or dangling txn log files so the temporary/obsoleted SSTable cleanup cannot complete.
Common situations: Node crashed during compaction leaving inconsistent txn logs; SSTable files manually removed while txn logs still reference them; data directory copied while writes were in flight.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Cannot remove temporary or obsoleted files for %s.%s due to
- Unknown kind in sstable
- Corrupt flags value for clustering prefix (isStatic flag set
- ERR_WRONG_DISK_STATE
- Unknown column <name> during deserialization
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/5690c537584e4cbd.
Report an issue: GitHub.