{"record":{"id":"98ef2036644cf173","repo":"apache/cassandra","slug":"err-wrong-disk-state","errorCode":"ERR_WRONG_DISK_STATE","errorMessage":"Cannot remove temporary or obsoleted files for %s due to a problem with transaction log files. Please check records with problems in the log messages above and fix them. Refer to the 3.0 upgrading instructions in NEWS.txt for a description of transaction log files.","messagePattern":"Cannot remove temporary or obsoleted files for (.+?) due to a problem with transaction log files\\. Please check records with problems in the log messages above and fix them\\. Refer to the 3\\.0 upgrading instructions in NEWS\\.txt for a description of transaction log files\\.","errorType":"error_code","errorClass":"org.apache.cassandra.io.util.StartupException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/db/ColumnFamilyStore.java","lineNumber":833,"sourceCode":"        return new ColumnFamilyStore(keyspace, columnFamily,\n                                     directories.getUIDGenerator(SSTableIdFactory.instance.defaultBuilder()),\n                                     metadata, directories, loadSSTables, registerBookkeeping, addIndexes);\n    }\n\n    /**\n     * Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files\n     * and compacted sstables. Files that cannot be recognized will be ignored.\n     */\n    public static void scrubDataDirectories(TableMetadata metadata) throws StartupException\n    {\n        Directories directories = new Directories(metadata);\n        Set<File> cleanedDirectories = new HashSet<>();\n\n        directories.removeTemporaryDirectories();\n\n        logger.trace(\"Removing temporary or obsoleted files from unfinished operations for table {}\", metadata.name);\n        if (!LifecycleTransaction.removeUnfinishedLeftovers(metadata))\n            throw new StartupException(StartupException.ERR_WRONG_DISK_STATE,\n                                       String.format(\"Cannot remove temporary or obsoleted files for %s due to a problem with transaction \" +\n                                                     \"log files. Please check records with problems in the log messages above and fix them. \" +\n                                                     \"Refer to the 3.0 upgrading instructions in NEWS.txt \" +\n                                                     \"for a description of transaction log files.\", metadata));\n\n        logger.trace(\"Further extra check for orphan sstable files for {}\", metadata.name);\n        for (Map.Entry<Descriptor,Set<Component>> sstableFiles : directories.sstableLister(Directories.OnTxnErr.IGNORE).list().entrySet())\n        {\n            Descriptor desc = sstableFiles.getKey();\n            File directory = desc.directory;\n            Set<Component> components = sstableFiles.getValue();\n\n            if (!cleanedDirectories.contains(directory))\n            {\n                cleanedDirectories.add(directory);\n                for (File tmpFile : desc.getTemporaryFiles())\n                {\n                    logger.info(\"Removing unfinished temporary file {}\", tmpFile);","sourceCodeStart":815,"sourceCodeEnd":851,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/ColumnFamilyStore.java#L815-L851","documentation":"During table initialization (after restart), Cassandra removes temporary and obsoleted files left behind by unfinished compactions/flushes using the transaction log (sstable activity) files. If LifecycleTransaction.removeUnfinishedLeftovers reports records with problems, startup of the table is aborted with a StartupException (ERR_WRONG_DISK_STATE) so the operator can fix disk state manually rather than silently deleting or losing data.","triggerScenarios":"Node restart/startup for a table whose transaction log files reference files that are missing, still present unexpectedly, or otherwise inconsistent - detected in ColumnFamilyStore initialization after directories.removeTemporaryDirectories().","commonSituations":"Interrupted upgrades from pre-3.0, manually copying/deleting sstable files while transaction logs remain, restore/snapshot operations that moved sstables without their _txn companions, disk failures or partial rsync of data dirs.","solutions":["Read the 'records with problems' log messages above the exception and manually reconcile the listed files (delete or complete the transaction as guided)","Follow the 3.0 upgrading instructions in NEWS.txt for transaction log file handling","Remove orphaned sstable files together with their matching *_txn leftovers per the recorded transactions; when in doubt remove only the obsolete temp files listed and retry startup","Restore the table's data directory from a consistent backup/snapshot, then start again"],"exampleFix":"// before\n// startup fails with ERR_WRONG_DISK_STATE; data dir has stale sstable without matching txn records\n// after\n# remove the stale sstable + its *_txn leftover per NEWS.txt 3.0 instructions, then:\nnodetool drain && systemctl restart cassandra  -> startup succeeds","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"// StartupException cannot be caught in-process; treat as operator alert\ntry { startNode(); } catch (StartupException e) { if (e.errorCode == StartupException.ERR_WRONG_DISK_STATE) { pageOnCall(\"reconcile txn log leftovers per NEWS.txt\"); } }","preventionTips":["Never manually delete/move sstables without their matching transaction log (_txn) files","Use snapshots/nodetool for data movement instead of raw file copies","Drain nodes (nodetool drain) before planned shutdowns","Follow NEWS.txt 3.0 upgrade instructions before upgrading"],"tags":["cassandra","startup","disk-state","transaction-log"],"backgroundTag":"invalid-state-transition","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}