{"record":{"id":"20534690c4d7b2dc","repo":"apache/cassandra","slug":"you-can-not-store-async-profiler-results-into-syst","errorCode":null,"errorMessage":"You can not store Async-Profiler results into system Cassandra directory.","messagePattern":"You can not store Async-Profiler results into system Cassandra directory\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/AsyncProfilerService.java","lineNumber":433,"sourceCode":"    {\n        int durationSeconds = new DurationSpec.IntSecondsBound(duration).toSeconds();\n        if (durationSeconds > MAX_SAFE_PROFILING_DURATION)\n            throw new IllegalArgumentException(format(\"Max profiling duration is %s seconds. If you need longer profiling, use execute command instead.\",\n                                                      MAX_SAFE_PROFILING_DURATION));\n        return durationSeconds;\n    }\n\n    private static void maybeCreateProfilesLogDir()\n    {\n        String dir = new File(logDir).toAbsolute().toString();\n\n        if ((DatabaseDescriptor.getCommitLogLocation() != null && dir.startsWith(DatabaseDescriptor.getCommitLogLocation())) ||\n            (DatabaseDescriptor.getAccordJournalDirectory() != null && dir.startsWith(DatabaseDescriptor.getAccordJournalDirectory())) ||\n            dir.startsWith(DatabaseDescriptor.getHintsDirectory().absolutePath()) ||\n            (DatabaseDescriptor.getCDCLogLocation() != null && dir.startsWith(DatabaseDescriptor.getCDCLogLocation())) ||\n            (DatabaseDescriptor.getSavedCachesLocation() != null && dir.startsWith(DatabaseDescriptor.getSavedCachesLocation())))\n        {\n            throw new RuntimeException(\"You can not store Async-Profiler results into system Cassandra directory.\");\n        }\n\n        for (String location : StorageService.instance.getAllDataFileLocations())\n        {\n            if (dir.startsWith(location))\n                throw new RuntimeException(\"You can not store Async-Profiler results into a data directory of Cassandra.\");\n        }\n\n        try\n        {\n            new File(logDir).createDirectoriesIfNotExists();\n        }\n        catch (Throwable t)\n        {\n            throw new RuntimeException(\"Unable to create directory \" + logDir);\n        }\n    }\n","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/AsyncProfilerService.java#L415-L451","documentation":"maybeCreateProfilesLogDir refuses to place the Async-Profiler log directory inside protected Cassandra system directories (commit log, accord journal, hints, CDC log, saved caches). Writing profiler output there could corrupt or contaminate critical operational data, so a RuntimeException is thrown when the configured log dir resolves under one of those locations.","triggerScenarios":"Setting the async-profiler log directory (via the relevant cassandra config/property) to a path at or under the commitlog directory, hints directory, CDC log location, accord journal directory, or saved caches location, then calling instance()/apply()/list()/fetch()/purge().","commonSituations":"Operators pointing 'all Cassandra dirs' to one big mount; copy-pasted cassandra.yaml where the profiler log dir equals commitlog_location; container images sharing a single volume root.","solutions":["Move the profiler log directory to a dedicated path outside all Cassandra system directories (e.g. /var/log/cassandra/async-profiler)","Check the resolved dir against commitlog/hints/CDC/saved-caches/accord-journal locations in cassandra.yaml before starting","Use the default log dir rather than overriding it onto a system path"],"exampleFix":"// before\nasync_profiler_dir: /var/lib/cassandra/commitlog/prof\n// after\nasync_profiler_dir: /var/log/cassandra/async-profiler","handlingStrategy":"validation","validationCode":"String dir = Path.of(profilerLogDir).toAbsolutePath().toString();\nList<String> forbidden = List.of(DatabaseDescriptor.getCommitLogLocation(), DatabaseDescriptor.getHintsDirectory().absolutePath(), DatabaseDescriptor.getCDCLogLocation(), DatabaseDescriptor.getSavedCachesLocation());\nif (forbidden.stream().anyMatch(l -> l != null && dir.startsWith(l))) throw new IllegalArgumentException(\"profiler log dir must not be a Cassandra system directory\");","typeGuard":null,"tryCatchPattern":"try { svc.list(); } catch (RuntimeException e) { if (e.getMessage().contains(\"system Cassandra directory\")) { log.error(\"reconfigure async-profiler log dir\"); throw e; } throw e; }","preventionTips":["Dedicate a log filesystem for profiler output","Review cassandra.yaml so profiler dirs never coincide with commitlog/hints/CDC/saved-caches/accord-journal paths","Validate dir prefixes at config-load time"],"tags":["configuration","filesystem","data-safety"],"backgroundTag":"invalid-config-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}