{"record":{"id":"45771af6852b86fb","repo":"aeron-io/aeron","slug":"election-in-progress","errorCode":null,"errorMessage":"election in progress","messagePattern":"election in progress","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"aeron-cluster/src/main/java/io/aeron/cluster/ConsensusModuleAgent.java","lineNumber":3064,"sourceCode":"        }\n\n        if (!uncommittedPreviousState.isEmpty())\n        {\n            uncommittedPreviousState.pollLong();\n            final ConsensusModule.State committedState = ConsensusModule.State.get(uncommittedPreviousState.pollLong());\n            if (ConsensusModule.State.CLOSED != state)\n            {\n                state(committedState, \"rollback\");\n            }\n        }\n        uncommittedPreviousState.clear();\n    }\n\n    private void enterElection(final boolean isLogEndOfStream, final String reason)\n    {\n        if (null != election)\n        {\n            throw new IllegalStateException(\"election in progress\");\n        }\n\n        role(Cluster.Role.FOLLOWER);\n\n        final long leadershipTermId = this.leadershipTermId;\n        final RecordingLog.Entry termEntry = recordingLog.findTermEntry(leadershipTermId);\n        final long termBaseLogPosition = null != termEntry ?\n            termEntry.termBaseLogPosition : recoveryPlan.lastTermBaseLogPosition();\n        final long appendedPosition = null != appendPosition ?\n            appendPosition.get() : max(recoveryPlan.appendedLogPosition(), logRecordingStopPosition);\n        final long commitPosition = this.commitPosition.getPlain();\n\n        logNewElection(memberId, leadershipTermId, commitPosition, appendedPosition, reason);\n        ctx.countedErrorHandler().onError(new ClusterEvent(reason));\n\n        election = new Election(\n            false,\n            isLogEndOfStream ? leaderMember.id() : NULL_VALUE,","sourceCodeStart":3046,"sourceCodeEnd":3082,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-cluster/src/main/java/io/aeron/cluster/ConsensusModuleAgent.java#L3046-L3082","documentation":"enterElection starts a new cluster election. The module allows only one election at a time; if enterElection is called while an election object is already active, IllegalStateException is thrown to signal the internal state machine was violated.","triggerScenarios":"Thrown when election != null upon entering enterElection, e.g. an end-of-stream event or failure triggers a second election while the current one is still in progress.","commonSituations":"Leader and follower connectivity flapping, generating repeated end-of-stream events; a bug or race in election completion logic; concurrent failure events arriving during an active election.","solutions":["Capture full agent logs to see why enterElection was re-entered (reason string is logged)","Check for network flapping causing repeated end-of-stream signals","Update Aeron to the latest patch release; several election re-entry races have been fixed","Restart the node to clear the stuck election state"],"exampleFix":"// before: re-entering election without checking state\nagent.enterElection(isEos, reason);\n\n// after: guard with election null check\nif (null == election)\n{\n    agent.enterElection(isEos, reason);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IllegalStateException e)\n{\n    if (\"election in progress\".equals(e.getMessage()))\n    {\n        log.warn(\"election re-entry attempt ignored\");\n        return; // let the active election finish\n    }\n    throw e;\n}","preventionTips":["Guard all election entry points with a null election check","Fix network flapping that generates repeated end-of-stream events","Keep Aeron updated; election races are patched in maintenance releases","Serialize election-triggering events through the agent duty cycle only"],"tags":["aeron","cluster","election","state-machine","illegal-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}