{"record":{"id":"2b323e3d25490d6e","repo":"SonarSource/sonarqube","slug":"this-node-has-a-cluster-name-s-which-does-not","errorCode":null,"errorMessage":"This node has a cluster name [%s], which does not match [%s] from the cluster","messagePattern":"This node has a cluster name \\[(.+?)\\], which does not match \\[(.+?)\\] from the cluster","errorType":"validation","errorClass":"MessageException","httpStatus":null,"severity":"error","filePath":"server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java","lineNumber":178,"sourceCode":"\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) {\n    DistributedReference<String> property = hzMember.getAtomicReference(CLUSTER_NAME);\n    boolean wasSet = property.compareAndSet(null, clusterName);\n\n    if (!wasSet) {\n      String clusterValue = property.get();\n      if (!property.get().equals(clusterName)) {\n        throw new MessageException(\n          format(\"This node has a cluster name [%s], which does not match [%s] from the cluster\", clusterName, clusterValue));\n      }\n    }\n  }\n\n  @Override\n  public Optional<String> getLeaderHostName() {\n    UUID leaderUuid = (UUID) hzMember.getAtomicReference(LEADER).get();\n    if (leaderUuid != null) {\n      Optional<Member> leader = hzMember.getCluster().getMembers().stream().filter(m -> m.getUuid().equals(leaderUuid)).findFirst();\n      if (leader.isPresent()) {\n        return Optional.of(leader.get().getAddress().getHost());\n      }\n    }\n    return Optional.empty();\n  }\n\n  @Override","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java#L160-L196","documentation":"registerClusterName stores the cluster name in a Hazelcast atomic reference; the first node wins and every other node must present the identical name. A node whose configured cluster name differs from the cluster's registered value is rejected with a MessageException, since differently named nodes must not join the same Hazelcast cluster.","triggerScenarios":"Starting a node whose sonar.cluster.name (clusterName parameter) does not equal the name already registered by other members — usually a copy-pasted or stale configuration on one node.","commonSituations":"Cloning configuration between environments and forgetting to change sonar.cluster.name, typos or trailing whitespace in one node's config, or adding a new node copied from an old template.","solutions":["Set sonar.cluster.name on the failing node to exactly match the value used by the other cluster members","Compare the configured name with the cluster name logged by healthy members (watch for case/whitespace differences)","Regenerate the node configuration from the current cluster's reference configuration","Ensure load balancer and Hazelcast discovery configs reference one single consistent cluster name"],"exampleFix":"// before (node conf/sonar.properties)\nsonar.cluster.name=prod-sonarqube-cluster\n// after (match existing members)\nsonar.cluster.name=production-sonar","handlingStrategy":"validation","validationCode":"String myName = props.getProperty(\"sonar.cluster.name\");\nif (myName == null || myName.trim().isEmpty() || !myName.equals(EXPECTED_CLUSTER_NAME)) {\n  throw new IllegalArgumentException(\"sonar.cluster.name mismatch: \" + myName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  node.start();\n} catch (MessageException e) {\n  if (e.getMessage().contains(\"does not match\")) {\n    log.error(\"Cluster name mismatch: fix sonar.cluster.name to match other members\", e);\n  }\n}","preventionTips":["Keep sonar.cluster.name identical across all nodes (no trailing whitespace)","Template cluster configs from a single source of truth","Diff new node configs against a healthy member before joining"],"tags":["java","cluster","configuration"],"backgroundTag":"conflicting-config-options","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"}