Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
create test case which shows quorum calculation is wrong (#6427)
Browse files Browse the repository at this point in the history
Quorum is now correctly calculated when validating cluster topology.
  • Loading branch information
Sam-Kramer authored Jan 30, 2023
1 parent a21a540 commit 08b8a9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private ClusterTopologyResult maybeGetConsistentClusterTopology(

// Only consider hosts that have the endpoint for quorum calculations.
// Otherwise, we will never add hosts when we're in a mixed state
int quorum = (hostIdsByServerWithoutSoftFailures.size() + 1) / 2;
int quorum = (hostIdsByServerWithoutSoftFailures.size() / 2) + 1;

// If too many hosts are unreachable, then we cannot come to a consensus
if (hostIdsWithoutFailures.size() < quorum) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ public void validateNewlyAddedHostsNewHostsNotAddedIfTheyDisagreeWithOldHostsOnP

@Test
public void validateNewlyAddedHostsNoNewHostsAddedIfNewHostsDoNotHaveQuorumAndNoCurrentServers() {
Map<CassandraServer, CassandraClientPoolingContainer> allHosts = setupHosts(NEW_HOSTS);
Set<String> hosts = ImmutableSet.<String>builder()
.addAll(NEW_HOSTS)
.add(OLD_HOST_ONE)
.build();
Map<CassandraServer, CassandraClientPoolingContainer> allHosts = setupHosts(hosts);
Set<String> hostsOffline = ImmutableSet.of(NEW_HOST_ONE, NEW_HOST_TWO);
setHostIds(filterContainers(allHosts, hostsOffline::contains), HostIdResult.hardFailure());
setHostIds(filterContainers(allHosts, server -> !hostsOffline.contains(server)), HostIdResult.success(UUIDS));
Expand Down
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-6427.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: 'Fixes bug where quorum calculation was incorrect for topology validation. '
links:
- https://github.com/palantir/atlasdb/pull/6427

0 comments on commit 08b8a9b

Please sign in to comment.