{"record":{"id":"58964a3f62762b6f","repo":"apache/cassandra","slug":"failed-importing-sstables","errorCode":null,"errorMessage":"Failed importing SSTables","messagePattern":"Failed importing SSTables","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/SSTableImporter.java","lineNumber":206,"sourceCode":"                    {\n                        logger.error(\"[{}] Failed importing sstables in directory {}\", importID, dir, t);\n                        failedDirectories.add(dir);\n                        if (options.copyData)\n                        {\n                            removeCopiedSSTables(movedSSTables);\n                        }\n                        else\n                        {\n                            moveSSTablesBack(movedSSTables);\n                        }\n                        movedSSTables.clear();\n                        newSSTablesPerDirectory.clear();\n                        break;\n                    }\n                    else\n                    {\n                        logger.error(\"[{}] Failed importing sstables from data directory - renamed SSTables are: {}\", importID, movedSSTables, t);\n                        throw new RuntimeException(\"Failed importing SSTables\", t);\n                    }\n                }\n            }\n            newSSTables.addAll(newSSTablesPerDirectory);\n        }\n\n        if (newSSTables.isEmpty())\n        {\n            logger.info(\"[{}] No new SSTables were found for {}/{}\", importID, cfs.getKeyspaceName(), cfs.getTableName());\n            return failedDirectories;\n        }\n\n        logger.info(\"[{}] Loading new SSTables and building secondary indexes for {}/{}: {}\", importID, cfs.getKeyspaceName(), cfs.getTableName(), newSSTables);\n        if (logger.isTraceEnabled())\n            logLeveling(importID, newSSTables);\n\n        try (Refs<SSTableReader> refs = Refs.ref(newSSTables))\n        {","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/SSTableImporter.java#L188-L224","documentation":"When moving/copying imported SSTables into the live data directory fails, SSTableImporter.importNewSSTables logs the failure and throws RuntimeException 'Failed importing SSTables' with the cause, aborting that directory's import. The rename/move of the prepared SSTables into place did not succeed.","triggerScenarios":"importNewSSTables moves verified, renamed SSTables from the staging/import directory to the table's data directory; an I/O error (disk full, permission denied, cross-device rename, existing target files) occurs and the directory is not a designated failed directory.","commonSituations":"Insufficient disk space on the target data volume; import directory on a different filesystem than the data directory; leftover files from a previous failed import with the same names; permission mismatch between the importer process and Cassandra's data dirs.","solutions":["Free disk space on the target data directory and retry the import","Run the import so staging and the data directory share the same filesystem (rename must be same-device)","Remove stale/partial files from previous failed imports in both the import and data directories, then retry","Fix file ownership/permissions so the Cassandra user can write into the table's data directory"],"exampleFix":"// before: import dir on a different filesystem than data dir\nnodetool import -- ks table /mnt/usb/import   # cross-device move fails\n// after: stage on same filesystem as data\nmkdir /var/lib/cassandra/data/import && cp /mnt/usb/import/* /var/lib/cassandra/data/import/\nnodetool import -- ks table /var/lib/cassandra/data/import","handlingStrategy":"validation","validationCode":"// preflight before import\nassertSameFilesystem(importDir, tableDataDir);\nrequireFreeSpace(tableDataDir, sizeOf(importDir) * 1.2);\nrequireWritableBy(tableDataDir, cassandraUser);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the import directory on the same filesystem as the table's data directory","Ensure ample free space (import roughly doubles the data temporarily)","Clean leftovers of failed imports before retrying","Run nodetool import as the Cassandra user with correct permissions"],"tags":["sstable","import","io","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}