{"record":{"id":"58944881cdb2983d","repo":"apache/cassandra","slug":"already-logging-to","errorCode":null,"errorMessage":"Already logging to ","messagePattern":"Already logging to ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/binlog/BinLog.java","lineNumber":449,"sourceCode":"        {\n            this.maxArchiveRetries = maxArchiveRetries;\n            return this;\n        }\n\n        public Builder blocking(boolean blocking)\n        {\n            this.blocking = blocking;\n            return this;\n        }\n\n\n        public BinLog build(boolean cleanDirectory)\n        {\n            logger.info(\"Attempting to configure bin log: Path: {} Roll cycle: {} Blocking: {} Max queue weight: {} Max log size:{} Archive command: {}\", path, rollCycle, blocking, maxQueueWeight, maxLogSize, archiveCommand);\n            synchronized (currentPaths)\n            {\n                if (currentPaths.contains(path))\n                    throw new IllegalStateException(\"Already logging to \" + path);\n                currentPaths.add(path);\n            }\n            try\n            {\n                Throwable sanitationThrowable = cleanEmptyLogFiles(new File(path), null);\n                if (sanitationThrowable != null)\n                    throw new RuntimeException(format(\"Unable to clean up %s directory from empty %s files.\",\n                                                      path.toAbsolutePath(), SingleChronicleQueue.SUFFIX),\n                                               sanitationThrowable);\n\n                // create the archiver before cleaning directories - ExternalArchiver will try to archive any existing file.\n                BinLogArchiver archiver = Strings.isNullOrEmpty(archiveCommand) ? new DeletingArchiver(maxLogSize) : new ExternalArchiver(archiveCommand, path, maxArchiveRetries);\n                if (cleanDirectory)\n                {\n                    logger.info(\"Cleaning directory: {} as requested\", path);\n                    if (new File(path).exists())\n                    {\n                        Throwable error = cleanDirectory(new File(path), null);","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/binlog/BinLog.java#L431-L467","documentation":"BinLog (the Chronicle-Queue-backed binary log used for full query logging / audit logging) refuses to build a second BinLog targeting the same directory path. The static `currentPaths` set tracks every active log path across all BinLog instances; if the path is already registered, `build()` throws IllegalStateException. This prevents two writers corrupting the same chronicle queue directory.","triggerScenarios":"Calling BinLog.Builder.build() (e.g. re-enabling full query logging or audit logging via JMX/nodetool `enablefullquerylog`) while another BinLog instance is already active on the same path, or after a previous instance failed to release the path (the path is removed from currentPaths only when the BinLog is stopped).","commonSituations":"Enabling FQL twice without stopping it first; enabling FQL and audit logging pointed at the same directory; a leaked BinLog from a failed startup keeping the path registered; configuration reload that rebuilds the logger without calling stop().","solutions":["Stop the existing BinLog first (nodetool disablefullquerylog / disableauditlog, or call stop() on the existing instance) before rebuilding.","Use a different log directory path for the new BinLog.","If a previous instance crashed and leaked the path registration, restart the node so the static set is cleared.","Inspect fullquerylog/audit log config in cassandra.yaml and ensure only one subsystem owns the directory."],"exampleFix":"// before\n// FQL enabled while already running on same path\nbinLogBuilder.build(true); // throws IllegalStateException: Already logging to ...\n// after\nif (BinLog.isRunning()) // stop existing logger first\n    BinLog.instance().stop();\nbinLogBuilder.build(true);","handlingStrategy":"try-catch","validationCode":"// before building\nPath p = Paths.get(fqlDir);\nboolean active = BinLog.isRunning(); // or track instances yourself\nif (active && p.toAbsolutePath().equals(activePath)) throw new IllegalStateException(\"FQL already running on \" + p);","typeGuard":null,"tryCatchPattern":"try { builder.build(true); } catch (IllegalStateException e) { logger.warn(\"BinLog already active: {}\", e.getMessage()); /* stop existing instance and retry, or use different path */ }","preventionTips":["Always pair enablefullquerylog with disablefullquerylog before reconfiguring.","Use distinct directories for FQL and audit logs.","Track BinLog lifecycle centrally rather than rebuilding ad hoc.","On startup failures, stop() the partially built BinLog so currentPaths is released."],"tags":["logging","configuration","illegal-state"],"backgroundTag":"conflicting-config-options","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"}