Merge branch 'cassandra-3.11' into cassandra-4.0

This commit is contained in:
Stefan Miklosovic 2023-08-31 10:32:30 +02:00
commit 94043fa9c6
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
2 changed files with 19 additions and 27 deletions

View File

@ -6,6 +6,7 @@ Merged from 3.11:
* Fix NPE when using udfContext in UDF after a restart of a node (CASSANDRA-18739) * Fix NPE when using udfContext in UDF after a restart of a node (CASSANDRA-18739)
* Moved jflex from runtime to build dependencies (CASSANDRA-18664) * Moved jflex from runtime to build dependencies (CASSANDRA-18664)
Merged from 3.0: Merged from 3.0:
* Refactor validation logic in StorageService.rebuild (CASSANDRA-18803)
* Make alternation of a user type validate the same way as creation of a user type does (CASSANDRA-18585) * Make alternation of a user type validate the same way as creation of a user type does (CASSANDRA-18585)
* Backport of CASSANDRA-16905 Further restrict schema column drop/recreate conversions (CASSANDRA-18760) * Backport of CASSANDRA-16905 Further restrict schema column drop/recreate conversions (CASSANDRA-18760)
* CQLSH emits a warning when the server version doesn't match (CASSANDRA-18745) * CQLSH emits a warning when the server version doesn't match (CASSANDRA-18745)

View File

@ -1327,43 +1327,34 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
public void rebuild(String sourceDc, String keyspace, String tokens, String specificSources) public void rebuild(String sourceDc, String keyspace, String tokens, String specificSources)
{ {
try if (sourceDc != null)
{ {
// check ongoing rebuild TokenMetadata.Topology topology = getTokenMetadata().cloneOnlyTokenMap().getTopology();
if (!isRebuilding.compareAndSet(false, true)) Set<String> availableDCs = topology.getDatacenterEndpoints().keySet();
if (!availableDCs.contains(sourceDc))
{ {
throw new IllegalStateException("Node is still rebuilding. Check nodetool netstats."); throw new IllegalArgumentException(String.format("Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s",
} sourceDc, String.join(",", availableDCs)));
if (sourceDc != null)
{
TokenMetadata.Topology topology = getTokenMetadata().cloneOnlyTokenMap().getTopology();
Set<String> availableDCs = topology.getDatacenterEndpoints().keySet();
if (!availableDCs.contains(sourceDc))
{
throw new IllegalArgumentException(String.format("Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s",
sourceDc, String.join(",", availableDCs)));
}
}
// check the arguments
if (keyspace == null && tokens != null)
{
throw new IllegalArgumentException("Cannot specify tokens without keyspace.");
} }
} }
catch (Throwable ex)
if (keyspace == null && tokens != null)
{ {
isRebuilding.set(false); throw new IllegalArgumentException("Cannot specify tokens without keyspace.");
throw ex;
} }
logger.info("rebuild from dc: {}, {}, {}", sourceDc == null ? "(any dc)" : sourceDc, // check ongoing rebuild
keyspace == null ? "(All keyspaces)" : keyspace, if (!isRebuilding.compareAndSet(false, true))
tokens == null ? "(All tokens)" : tokens); {
throw new IllegalStateException("Node is still rebuilding. Check nodetool netstats.");
}
try try
{ {
logger.info("rebuild from dc: {}, {}, {}", sourceDc == null ? "(any dc)" : sourceDc,
keyspace == null ? "(All keyspaces)" : keyspace,
tokens == null ? "(All tokens)" : tokens);
RangeStreamer streamer = new RangeStreamer(tokenMetadata, RangeStreamer streamer = new RangeStreamer(tokenMetadata,
null, null,
FBUtilities.getBroadcastAddressAndPort(), FBUtilities.getBroadcastAddressAndPort(),