This is an automated email from the ASF dual-hosted git repository. dcapwell pushed a commit to branch cassandra-5.0 in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 210ced3b7b6718b515631b8b1579aa6f6fc2dea3 Merge: 3b9881bfa6 1920571861 Author: David Capwell <dcapw...@apache.org> AuthorDate: Tue Oct 10 14:15:08 2023 -0700 Merge branch 'cassandra-4.1' into cassandra-5.0 CHANGES.txt | 1 + .../org/apache/cassandra/gms/EndpointState.java | 5 + .../org/apache/cassandra/gms/GossipShutdown.java | 66 +++++++++++++ .../cassandra/gms/GossipShutdownVerbHandler.java | 7 +- src/java/org/apache/cassandra/gms/Gossiper.java | 31 +++++- src/java/org/apache/cassandra/net/Verb.java | 5 +- .../test/gossip/GossipShutdownTest.java | 106 +++++++++++++++++++++ 7 files changed, 214 insertions(+), 7 deletions(-) diff --cc CHANGES.txt index 1e0fe54855,c5f2a1b92c..f40b4020d7 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,24 -1,12 +1,25 @@@ -4.1.4 +5.0-alpha2 + * Fix vector type to support DDM's mask_default function (CASSANDRA-18889) + * Remove unnecessary reporter-config3 dependency (CASSANDRA-18907) + * Remove support for empty values on the vector data type (CASSANDRA-18876) + * Upgrade Dropwizard Metrics to 4.2.19 (CASSANDRA-14667) + * Upgrade caffeine cache and fix CIDR permissions cache invalidation (CASSANDRA-18805) + * Remove deprecated properties in CompressionParams (CASSANDRA-18742) + * Add support for repair coordinator to retry messages that timeout (CASSANDRA-18816) + * Upgrade slf4j-api to 1.7.36 (CASSANDRA-18882) + * Make the output of ON/OFF commands in cqlsh consistent (CASSANDRA-18547) + * Do not create sstable files before registering in txn (CASSANDRA-18737) + * Do not log stacktrace on mismatched cache and schema version and checksum error in AutoSavingCache (CASSANDRA-18862) + * Remove wrong assertion in SSTableLoader (CASSANDRA-18840) + * Fix accessing java.nio.Bits.TOTAL_CAPACITY in Java17 (CASSANDRA-18848) + * Remove metrics-reporter-config dependency (CASSANDRA-18743) + * Fix SAI's SegmentMetadata min and max primary keys (CASSANDRA-18734) + * Remove commons-codec dependency (CASSANDRA-18772) +Merged from 4.1: * Internode legacy SSL storage port certificate is not hot reloaded on update (CASSANDRA-18681) * Nodetool paxos-only repair is no longer incremental (CASSANDRA-18466) - * Waiting indefinitely on ReceivedMessage response in StreamSession#receive() can cause deadlock (CASSANDRA-18733) - * Allow empty keystore_password in encryption_options (CASSANDRA-18778) - * Skip ColumnFamilyStore#topPartitions initialization when client or tool mode (CASSANDRA-18697) Merged from 4.0: + * Gossip NPE due to shutdown event corrupting empty statuses (CASSANDRA-18913) - * Fix closing iterator in SecondaryIndexBuilder (CASSANDRA-18361) * Update hdrhistogram to 2.1.12 (CASSANDRA-18893) * Improve performance of compactions when table does not have an index (CASSANDRA-18773) * JMH improvements - faster build and async profiler (CASSANDRA-18871) diff --cc src/java/org/apache/cassandra/gms/GossipShutdown.java index 0000000000,0000000000..02f0f375c4 new file mode 100644 --- /dev/null +++ b/src/java/org/apache/cassandra/gms/GossipShutdown.java @@@ -1,0 -1,0 +1,66 @@@ ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.cassandra.gms; ++ ++import java.io.IOException; ++ ++import javax.annotation.Nullable; ++ ++import org.apache.cassandra.io.IVersionedSerializer; ++import org.apache.cassandra.io.util.DataInputPlus; ++import org.apache.cassandra.io.util.DataOutputPlus; ++import org.apache.cassandra.net.MessagingService; ++ ++public class GossipShutdown ++{ ++ public static final Serializer serializer = new Serializer(); ++ ++ public final EndpointState state; ++ ++ public GossipShutdown(EndpointState state) ++ { ++ this.state = state; ++ } ++ ++ public static final class Serializer implements IVersionedSerializer<GossipShutdown> ++ { ++ ++ @Override ++ public void serialize(GossipShutdown t, DataOutputPlus out, int version) throws IOException ++ { ++ if (version < MessagingService.VERSION_50) return; ++ EndpointState.serializer.serialize(t.state, out, version); ++ } ++ ++ @Nullable ++ @Override ++ public GossipShutdown deserialize(DataInputPlus in, int version) throws IOException ++ { ++ if (version < MessagingService.VERSION_50) return null; ++ return new GossipShutdown(EndpointState.serializer.deserialize(in, version)); ++ } ++ ++ @Override ++ public long serializedSize(GossipShutdown t, int version) ++ { ++ if (version < MessagingService.VERSION_50) return 0; ++ return EndpointState.serializer.serializedSize(t.state, version); ++ } ++ } ++} diff --cc src/java/org/apache/cassandra/gms/GossipShutdownVerbHandler.java index f2622ef9b1,f2622ef9b1..9878520b81 --- a/src/java/org/apache/cassandra/gms/GossipShutdownVerbHandler.java +++ b/src/java/org/apache/cassandra/gms/GossipShutdownVerbHandler.java @@@ -23,20 -23,20 +23,21 @@@ import org.apache.cassandra.net.Message import org.slf4j.Logger; import org.slf4j.LoggerFactory; --public class GossipShutdownVerbHandler implements IVerbHandler ++public class GossipShutdownVerbHandler implements IVerbHandler<GossipShutdown> { public static final GossipShutdownVerbHandler instance = new GossipShutdownVerbHandler(); private static final Logger logger = LoggerFactory.getLogger(GossipShutdownVerbHandler.class); -- public void doVerb(Message message) ++ public void doVerb(Message<GossipShutdown> message) { if (!Gossiper.instance.isEnabled()) { logger.debug("Ignoring shutdown message from {} because gossip is disabled", message.from()); return; } -- Gossiper.instance.markAsShutdown(message.from()); ++ if (message.payload == null) Gossiper.instance.markAsShutdown(message.from()); ++ else Gossiper.instance.markAsShutdown(message.from(), message.payload.state); } } diff --cc src/java/org/apache/cassandra/gms/Gossiper.java index 43ee0aeea5,0d5db5f81c..54ea90a083 --- a/src/java/org/apache/cassandra/gms/Gossiper.java +++ b/src/java/org/apache/cassandra/gms/Gossiper.java @@@ -600,6 -586,6 +600,7 @@@ public class Gossiper implements IFailu * This method is used to mark a node as shutdown; that is it gracefully exited on its own and told us about it * @param endpoint endpoint that has shut itself down */ ++ @Deprecated(since = "5.0.0") // can remove once 4.x is not supported protected void markAsShutdown(InetAddressAndPort endpoint) { checkProperThreadForStateMutation(); @@@ -619,6 -605,6 +620,32 @@@ logger.debug("Marked {} as shutdown", endpoint); } ++ /** ++ * This method is used to mark a node as shutdown; that is it gracefully exited on its own and told us about it ++ * @param endpoint endpoint that has shut itself down ++ * @param remoteState from the endpoint shutting down ++ */ ++ protected void markAsShutdown(InetAddressAndPort endpoint, EndpointState remoteState) ++ { ++ checkProperThreadForStateMutation(); ++ EndpointState epState = endpointStateMap.get(endpoint); ++ if (epState == null || epState.isStateEmpty()) ++ return; ++ if (!VersionedValue.SHUTDOWN.equals(remoteState.getStatus())) ++ throw new AssertionError("Remote shutdown sent but was not with a shutdown status? " + remoteState); ++ // added in 5.0 so we know STATUS_WITH_PORT is set ++ VersionedValue shutdown = remoteState.getApplicationState(ApplicationState.STATUS_WITH_PORT); ++ if (shutdown == null) ++ throw new AssertionError("Remote shutdown sent but missing STATUS_WITH_PORT; " + remoteState); ++ endpointStateMap.put(endpoint, remoteState); ++ markDead(endpoint, remoteState); ++ FailureDetector.instance.forceConviction(endpoint); ++ GossiperDiagnostics.markedAsShutdown(this, endpoint); ++ for (IEndpointStateChangeSubscriber subscriber : subscribers) ++ subscriber.onChange(endpoint, ApplicationState.STATUS_WITH_PORT, shutdown); ++ logger.debug("Marked {} as shutdown", endpoint); ++ } ++ /** * Return either: the greatest heartbeat or application state * @@@ -2177,7 -2095,7 +2204,7 @@@ logger.info("Announcing shutdown"); addLocalApplicationState(ApplicationState.STATUS_WITH_PORT, StorageService.instance.valueFactory.shutdown(true)); addLocalApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.shutdown(true)); -- Message message = Message.out(Verb.GOSSIP_SHUTDOWN, noPayload); ++ Message<GossipShutdown> message = Message.out(Verb.GOSSIP_SHUTDOWN, new GossipShutdown(mystate)); for (InetAddressAndPort ep : liveEndpoints) MessagingService.instance().send(message, ep); Uninterruptibles.sleepUninterruptibly(SHUTDOWN_ANNOUNCE_DELAY_IN_MS.getInt(), TimeUnit.MILLISECONDS); diff --cc src/java/org/apache/cassandra/net/Verb.java index 2481674f09,d50a187fda..cc3c0a7d50 --- a/src/java/org/apache/cassandra/net/Verb.java +++ b/src/java/org/apache/cassandra/net/Verb.java @@@ -45,12 -45,12 +45,13 @@@ import org.apache.cassandra.db.Truncate import org.apache.cassandra.db.TruncateVerbHandler; import org.apache.cassandra.db.TruncateRequest; import org.apache.cassandra.exceptions.RequestFailureReason; --import org.apache.cassandra.gms.GossipDigestAck; import org.apache.cassandra.gms.GossipDigestAck2; import org.apache.cassandra.gms.GossipDigestAck2VerbHandler; ++import org.apache.cassandra.gms.GossipDigestAck; import org.apache.cassandra.gms.GossipDigestAckVerbHandler; import org.apache.cassandra.gms.GossipDigestSyn; import org.apache.cassandra.gms.GossipDigestSynVerbHandler; ++import org.apache.cassandra.gms.GossipShutdown; import org.apache.cassandra.gms.GossipShutdownVerbHandler; import org.apache.cassandra.hints.HintMessage; import org.apache.cassandra.hints.HintVerbHandler; @@@ -143,7 -142,7 +144,7 @@@ public enum Ver GOSSIP_DIGEST_SYN (14, P0, longTimeout, GOSSIP, () -> GossipDigestSyn.serializer, () -> GossipDigestSynVerbHandler.instance ), GOSSIP_DIGEST_ACK (15, P0, longTimeout, GOSSIP, () -> GossipDigestAck.serializer, () -> GossipDigestAckVerbHandler.instance ), GOSSIP_DIGEST_ACK2 (16, P0, longTimeout, GOSSIP, () -> GossipDigestAck2.serializer, () -> GossipDigestAck2VerbHandler.instance ), -- GOSSIP_SHUTDOWN (29, P0, rpcTimeout, GOSSIP, () -> NoPayload.serializer, () -> GossipShutdownVerbHandler.instance ), ++ GOSSIP_SHUTDOWN (29, P0, rpcTimeout, GOSSIP, () -> GossipShutdown.serializer, () -> GossipShutdownVerbHandler.instance ), ECHO_RSP (91, P0, rpcTimeout, GOSSIP, () -> NoPayload.serializer, () -> ResponseVerbHandler.instance ), ECHO_REQ (31, P0, rpcTimeout, GOSSIP, () -> NoPayload.serializer, () -> EchoVerbHandler.instance, ECHO_RSP ), --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org