{"record":{"id":"12b5e09013ce80b1","repo":"apache/cassandra","slug":"binlog-is-already-configured","errorCode":null,"errorMessage":"Binlog is already configured","messagePattern":"Binlog is already configured","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/fql/FullQueryLogger.java","lineNumber":95,"sourceCode":"    public static final String BATCH = \"batch\";\n    public static final String SINGLE_QUERY = \"single-query\";\n\n    public static final String QUERY = \"query\";\n    public static final String BATCH_TYPE = \"batch-type\";\n    public static final String QUERIES = \"queries\";\n    public static final String VALUES = \"values\";\n\n    private static final int EMPTY_LIST_SIZE = Ints.checkedCast(ObjectSizes.measureDeep(new ArrayList<>(0)));\n    private static final int EMPTY_BYTEBUF_SIZE;\n\n    public static final FullQueryLogger instance = new FullQueryLogger();\n\n    volatile BinLog binLog;\n\n    public synchronized void enable(Path path, String rollCycle, boolean blocking, int maxQueueWeight, long maxLogSize, String archiveCommand, int maxArchiveRetries)\n    {\n        if (this.binLog != null)\n            throw new IllegalStateException(\"Binlog is already configured\");\n        this.binLog = new BinLog.Builder().path(path)\n                                          .rollCycle(rollCycle)\n                                          .blocking(blocking)\n                                          .maxQueueWeight(maxQueueWeight)\n                                          .maxLogSize(maxLogSize)\n                                          .archiveCommand(archiveCommand)\n                                          .maxArchiveRetries(maxArchiveRetries)\n                                          .build(true);\n        QueryEvents.instance.registerListener(this);\n    }\n\n    public synchronized void enableWithoutClean(Path path, String rollCycle, boolean blocking, int maxQueueWeight, long maxLogSize, String archiveCommand, int maxArchiveRetries)\n    {\n        if (this.binLog != null)\n            throw new IllegalStateException(\"Binlog is already configured\");\n        this.binLog = new BinLog.Builder().path(path)\n                                          .rollCycle(rollCycle)\n                                          .blocking(blocking)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/fql/FullQueryLogger.java#L77-L113","documentation":"FullQueryLogger.enable() throws this IllegalStateException if a BinLog instance is already attached to the singleton FullQueryLogger. Full query logging (fql) is an exclusive resource: only one binlog (writer, path, roll cycle) can be active at a time, so re-enabling without first calling stop()/disable() is rejected. It is a guarded state transition, not an I/O failure.","triggerScenarios":"Calling FullQueryLogger.instance.enable(...) (directly or via nodetool enablefullquerylog / JMX) when fql was already enabled earlier in the node's lifetime and never disabled. Also triggered by scripting enable twice, or enable() after enableWithoutClean() without a disable in between.","commonSituations":"Automation/ops scripts that call enablefullquerylog on every deploy without checking current state; restoring a config-management run that re-applies an fql setting; mistakenly assuming enable() is idempotent (it reconfigures nothing — the existing binlog keeps its original parameters).","solutions":["Check current state first with FullQueryLogger.instance.isEnabled() and skip enable() if already true.","Call FullQueryLogger.instance.stop() (nodetool disablefullquerylog) before re-enabling with new parameters.","If the intent was to change parameters, disable, then enable with the desired path/rollCycle/maxLogSize.","If fql state is stale after a failed shutdown, ensure the binlog is closed (stop()) before retrying enable."],"exampleFix":"// before\nfullQueryLogger.enable(path, rollCycle, blocking, weight, maxLogSize, archiveCommand, retries);\n// after\nif (!fullQueryLogger.isEnabled())\n{\n    fullQueryLogger.enable(path, rollCycle, blocking, weight, maxLogSize, archiveCommand, retries);\n}\nelse\n{\n    fullQueryLogger.stop();\n    fullQueryLogger.enable(path, rollCycle, blocking, weight, maxLogSize, archiveCommand, retries);\n}","handlingStrategy":"validation","validationCode":"if (FullQueryLogger.instance.isEnabled())\n    throw new IllegalStateException(\"FQL already enabled; call stop() first\");","typeGuard":null,"tryCatchPattern":"try { fql.enable(...); } catch (IllegalStateException e) { logger.info(\"FQL already enabled, ignoring: {}\", e.getMessage()); }","preventionTips":["Always check isEnabled() before enable()/enableWithoutClean().","Make enable/disable idempotent in automation by calling stop() before enable().","Pair every enablefullquerylog with a corresponding disablefullquerylog in scripts."],"tags":["java","state","fql","configuration"],"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-17T15:17:12.973Z"}