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

create test case which shows quorum calculation is wrong #6427

Merged
merged 4 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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