Skip to content
Open
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
12 changes: 10 additions & 2 deletions src/java/org/apache/cassandra/tcm/Commit.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.cassandra.tcm.membership.Directory;
import org.apache.cassandra.tcm.membership.EndpointLookup;
import org.apache.cassandra.tcm.membership.NodeId;
import org.apache.cassandra.tcm.membership.NodeState;
import org.apache.cassandra.tcm.membership.NodeVersion;
import org.apache.cassandra.tcm.serialization.Version;
import org.apache.cassandra.utils.FBUtilities;
Expand Down Expand Up @@ -461,6 +462,11 @@ InetAddressAndPort endpoint(NodeId id)
{
return endpoints.endpoint(id);
};

boolean hasLeft(NodeId id)
{
return directory.peerState(id) == NodeState.LEFT;
}
}

private final Supplier<RoutingHelper> routingSupplier;
Expand Down Expand Up @@ -490,10 +496,12 @@ public void send(Result result, InetAddressAndPort source)
{
InetAddressAndPort endpoint = routing.endpoint(peerId);
boolean upgraded = routing.isUpgraded(peerId);
// Do not replicate to self and to the peer that has requested to commit this message
boolean hasLeft = routing.hasLeft(peerId);
// Do not replicate to self, to any left nodes and to the peer that has requested to commit this message
if (endpoint.equals(FBUtilities.getBroadcastAddressAndPort()) ||
(source != null && source.equals(endpoint)) ||
!upgraded)
!upgraded ||
hasLeft)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -438,5 +439,20 @@ public void testPeersPostDecom() throws IOException
}
}

@Test
public void testDontReplicateToLeftNodes() throws IOException, TimeoutException
{
try (Cluster cluster = init(builder().withNodes(3)
.withConfig(config -> config.with(NETWORK, GOSSIP))
.start()))
{
cluster.get(2).nodetoolResult("decommission", "--force").asserts().success();
long mark = cluster.get(1).logs().mark();
cluster.coordinator(1).execute(withKeyspace("create table %s.tbl (id int primary key)"), ConsistencyLevel.ONE);
cluster.get(3).logs().watchFor("Enacted.*CreateTableStatement.*tbl");
assertTrue(cluster.get(1).logs().grep(mark, "Replicating newly committed transformations up to.*127.0.0.2.*").getResult().isEmpty());
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.apache.cassandra.tcm.ClusterMetadata;
import org.apache.cassandra.tcm.Epoch;
import org.apache.cassandra.tcm.membership.Directory;
import org.apache.cassandra.tcm.membership.MembershipUtils;
import org.apache.cassandra.tcm.membership.NodeAddresses;
import org.apache.cassandra.tcm.membership.NodeId;
import org.apache.cassandra.tcm.ownership.DataPlacement;
Expand Down Expand Up @@ -81,7 +80,8 @@ public void testPlacementChange()
DataPlacements.Builder builder = before.unbuild();
before.forEach((params, placement) -> {
Replica remove = placement.writes.byEndpoint().flattenValues().iterator().next();
Replica add = Replica.fullReplica(MembershipUtils.endpoint(99), remove.range());
// randomPlacements gives 127.0.0.{1-255} ip addresses, need to add a non-conflicting one here:
Replica add = Replica.fullReplica(InetAddressAndPort.getByNameUnchecked("127.0.1.99"), remove.range());
DataPlacement newPlacement = placement.unbuild()
.withoutWriteReplica(e.nextEpoch(), remove)
.withWriteReplica(e.nextEpoch(), add).build();
Expand Down