From 02cc5df0ed64ba1e746fdb2662f4442fa308abf4 Mon Sep 17 00:00:00 2001 From: Jon Meredith Date: Tue, 22 Oct 2019 09:17:21 -0600 Subject: [PATCH] In-JVM DTest: Set correct internode message version for upgrade test On instance startup, if using mock internode messaging, find out what version of internode messaging should be used for other endpoints and configure the messaging service. Also adds a more helpful diagnostic message when versions are not supported. Patch by Jon Meredith; Reviewed by Dinesh Joshi for CASSANDRA-15371 --- CHANGES.txt | 4 ++++ .../apache/cassandra/distributed/impl/Instance.java | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index fefd40a0c0..d3846437ce 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +2.2.16 + * In-JVM DTest: Set correct internode message version for upgrade test (CASSANDRA-15371) + + 2.2.15 * Catch non-IOException in FileUtils.close to make sure that all resources are closed (CASSANDRA-15225) * Handle exceptions during authentication/authorization (CASSANDRA-15041) diff --git a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java index e405d6ba51..d3f29550e7 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java @@ -293,6 +293,13 @@ public class Instance extends IsolatedExecutor implements IInvokableInstance try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(imessage.bytes()))) { int version = imessage.version(); + if (version > MessagingService.current_version) + { + throw new IllegalStateException(String.format("Node%d received message version %d but current version is %d", + this.config.num(), + version, + MessagingService.current_version)); + } MessagingService.validateMagic(input.readInt()); int id; @@ -492,7 +499,10 @@ public class Instance extends IsolatedExecutor implements IInvokableInstance ApplicationState.STATUS, new VersionedValue.VersionedValueFactory(partitioner).normal(Collections.singleton(tokens.get(i)))); Gossiper.instance.realMarkAlive(ep.address, Gossiper.instance.getEndpointStateForEndpoint(ep.address)); - MessagingService.instance().setVersion(ep.address, MessagingService.current_version); + int messagingVersion = cluster.get(ep).isShutdown() + ? MessagingService.current_version + : Math.min(MessagingService.current_version, cluster.get(ep).getMessagingVersion()); + MessagingService.instance().setVersion(ep.address, messagingVersion); } // check that all nodes are in token metadata