{"record":{"id":"8e987966a4d85795","repo":"SonarSource/sonarqube","slug":"state-reset-is-not-supported-in-cluster-mode","errorCode":null,"errorMessage":"state reset is not supported in cluster mode","messagePattern":"state reset is not supported in cluster mode","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java","lineNumber":153,"sourceCode":"  @Override\n  public void tryToReleaseWebLeaderLock() {\n    tryToReleaseWebLeaderLock(hzMember.getUuid());\n  }\n\n  /**\n   * Tries to release the lock of the cluster leader. It is safe to call this method even if one is not sure about the UUID of the leader.\n   * If all nodes call this method then we can be confident that the lock is released.\n   *\n   * @param uuidOfLeader - the UUID of the leader to release the lock. In case the UUID is not the leader's uuid this method has no effect.\n   */\n  private void tryToReleaseWebLeaderLock(UUID uuidOfLeader) {\n    DistributedReference<UUID> leader = hzMember.getAtomicReference(LEADER);\n    leader.compareAndSet(uuidOfLeader, null);\n  }\n\n  @Override\n  public void reset() {\n    throw new IllegalStateException(\"state reset is not supported in cluster mode\");\n  }\n\n  @Override\n  public void registerSonarQubeVersion(String sonarqubeVersion) {\n    DistributedReference<String> sqVersion = hzMember.getAtomicReference(SONARQUBE_VERSION);\n    boolean wasSet = sqVersion.compareAndSet(null, sonarqubeVersion);\n\n    if (!wasSet) {\n      String clusterVersion = sqVersion.get();\n      if (!sqVersion.get().equals(sonarqubeVersion)) {\n        throw new IllegalStateException(\n          format(\"The local version %s is not the same as the cluster %s\", sonarqubeVersion, clusterVersion));\n      }\n    }\n  }\n\n  @Override\n  public void registerClusterName(String clusterName) {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java#L135-L171","documentation":"ClusterAppStateImpl.reset() explicitly refuses to run when the node operates in cluster mode: state (leader, version, cluster name) lives in Hazelcast distributed references and cannot be wiped on a single member. Calling reset on a cluster-mode node is an unsupported operation by design.","triggerScenarios":"Calling reset() on a ClusterAppStateImpl instance backed by a Hazelcast member instead of the standalone (monolith) app state, e.g. via code paths or tests that reset process state on a cluster node.","commonSituations":"Administrative scripts or lifecycle hooks that call app state reset for standalone restarts being reused against a Search/Web/CE node joined to a cluster; running the same operational tooling against both standalone and clustered deployments.","solutions":["Do not call reset() on cluster-mode nodes; restart the individual node instead","Clear distributed state by shutting down and rejoining the cluster member (Hazelcast state is rebuilt on join)","Only use reset() with the standalone AppState (non-cluster ProcessLauncher deployment)","Refactor calling code to branch on cluster vs standalone mode before attempting a reset"],"exampleFix":"// before\nappState.reset();\n// after\nif (appState instanceof ClusterAppStateImpl) {\n  throw new UnsupportedOperationException(\"restart the node instead of resetting state in cluster mode\");\n}\nappState.reset();","handlingStrategy":"try-catch","validationCode":"boolean isClusterMode = Boolean.parseBoolean(System.getProperty(\"sonar.cluster.enabled\", \"false\"));\nif (isClusterMode) {\n  // skip reset(); restart the node instead\n}","typeGuard":"if (appState instanceof ClusterAppStateImpl) { /* reset not supported */ }","tryCatchPattern":"try {\n  appState.reset();\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"state reset is not supported in cluster mode\")) {\n    log.warn(\"Restart the cluster node instead of resetting state\");\n  }\n}","preventionTips":["Branch lifecycle code on cluster vs standalone mode before resetting state","Never reuse standalone reset tooling against cluster nodes","Treat node restart as the supported way to clear cluster node state"],"tags":["java","cluster","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}