You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/01/18 06:38:18 UTC
[GitHub] [cassandra] bereng opened a new pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
bereng opened a new pull request #870:
URL: https://github.com/apache/cassandra/pull/870
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r567800033
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
Review comment:
I can run that test alone with `ant testsome -Dtest.name=org.apache.cassandra.cql3.validation.operations.CreateTest -Dtest.methods=testCreateKeyspaceRFgtNodesWarns`. That produces a NPE while getting the warnings unless we call `requireNetwork()`. However, as you said there are other tests for warnings that pass without requiring network:
```
ant testsome -Dtest.name=org.apache.cassandra.cql3.ViewTest -Dtest.methods=testClientWarningOnCreate
ant testsome -Dtest.name=org.apache.cassandra.cql3.validation.entities.UFSecurityTest -Dtest.methods=testAmokUDF
ant testsome -Dtest.name=org.apache.cassandra.index.sasi.SASICQLTest -Dtest.methods=testClientWarningOnCreate
```
I'm not sure what is the reason for that difference, maybe it's related to where the call to `ClientWarn.instance.warn` is done?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573474113
##########
File path: src/java/org/apache/cassandra/locator/TokenMetadata.java
##########
@@ -1331,6 +1331,14 @@ public EndpointsForToken getWriteEndpoints(Token token, String keyspaceName, End
}
}
+ /**
+ * @return a (stable copy, won't be modified) datacenter to Endpoint map for all the nodes in the cluster.
+ */
Review comment:
Mmmm I will leave this one as it is so it aligns with the other javadocs in the class.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r572350596
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -17,7 +17,14 @@
*/
package org.apache.cassandra.dht;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
Review comment:
Unused import
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -75,8 +85,16 @@ public Keyspaces apply(Keyspaces schema)
throw ire("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
keyspace.params.validate(keyspaceName);
+ Keyspaces ksps = schema.withAddedOrUpdated(keyspace);
Review comment:
nit: I would name this keyspaces
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
I am also in favor to the polling. Less prone to flakiness even if it is not perfect
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -75,8 +85,16 @@ public Keyspaces apply(Keyspaces schema)
throw ire("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
keyspace.params.validate(keyspaceName);
+ Keyspaces ksps = schema.withAddedOrUpdated(keyspace);
- return schema.withAddedOrUpdated(keyspace);
+ if (ClientWarn.instance.getWarnings() != null)
Review comment:
Was the idea revised again? :-)
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +62,10 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
nit: I was wondering what happened to this suggestion? I see similar one in AlterKeyspaceStatement and it seems reasonable to me and in fashion with the C* code style :-)
##########
File path: src/java/org/apache/cassandra/locator/TokenMetadata.java
##########
@@ -1331,6 +1331,14 @@ public EndpointsForToken getWriteEndpoints(Token token, String keyspaceName, End
}
}
+ /**
+ * @return a (stable copy, won't be modified) datacenter to Endpoint map for all the nodes in the cluster.
+ */
Review comment:
nit: I would probably say "an unmodifiable Data Center to Endpoint map... "
Decided to mention it only as it will appear in the java doc, feel free to ignore :-)
##########
File path: test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java
##########
@@ -72,7 +69,7 @@ public void testCreateKeyspaceTableWarning() throws IOException
try (SimpleClient client = newSimpleClient(ProtocolVersion.CURRENT).connect(false))
{
- String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'2'}";
+ String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'1'}";
Review comment:
Do we really want this change?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571894188
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
well, the difference is for a person debugging the failures:
"warnings are not cleared up in the beginning"
vs
"1 was expected and got 2"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r566899298
##########
File path: src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java
##########
@@ -134,7 +134,7 @@ SummaryStatistics getAllocationRingOwnership(InetAddressAndPort endpoint)
abstract class StrategyAdapter implements ReplicationStrategy<InetAddressAndPort>
{
- // return true iff the provided endpoint occurs in the same virtual token-ring we are allocating for
+ // return true if the provided endpoint occurs in the same virtual token-ring we are allocating for
Review comment:
I think `iff` stands for "if and only if", is it not correct in the context?
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
+ {
+ // NTS
+ ClientWarn.instance.captureWarnings();
+ execute("CREATE KEYSPACE testABC WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 2 }");
+ List<String> warnings = ClientWarn.instance.getWarnings();
+ warnings.removeIf(s -> !s.equals("Your replication factor 2 for keyspace testabc is higher than the number of nodes 1 for datacenter datacenter1"));
Review comment:
```suggestion
warnings.removeIf(s -> !s.equals("Your replication factor 2 for keyspace testabc is higher than the number of nodes 1 for datacenter " + DATA_CENTER));
```
##########
File path: src/java/org/apache/cassandra/locator/SimpleStrategy.java
##########
@@ -88,6 +92,18 @@ public void validateOptions() throws ConfigurationException
{
validateOptionsInternal(configOptions);
validateReplicationFactor(configOptions.get(REPLICATION_FACTOR));
+
+ int nodeCount = StorageService.instance.getHostIdToEndpoint().size();
+ // nodeCount==0 on many tests
+ if (rf.fullReplicas > nodeCount && nodeCount!=0)
Review comment:
```suggestion
if (rf.fullReplicas > nodeCount && nodeCount != 0)
```
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -46,6 +48,7 @@
private final KeyspaceAttributes attrs;
private final boolean ifNotExists;
+ private HashSet<String> clientWarnings = new HashSet<>();
Review comment:
Nit: could be final
```suggestion
private final HashSet<String> clientWarnings = new HashSet<>();
```
##########
File path: src/java/org/apache/cassandra/locator/TokenMetadata.java
##########
@@ -1331,6 +1331,23 @@ public EndpointsForToken getWriteEndpoints(Token token, String keyspaceName, End
}
}
+ /**
+ * @return a (stable copy, won't be modified) datacenter to Endpoint map for all the nodes in the cluster.
+ */
+ public ImmutableMultimap<String, InetAddressAndPort> getDC2AllEndpoints(IEndpointSnitch snitch)
+ {
+ ImmutableMultimap.Builder<String, InetAddressAndPort> dc2Nodesbuilder = ImmutableMultimap.builder();
+ HashSet<InetAddressAndPort> nodes = new HashSet<InetAddressAndPort>(getAllEndpoints());
Review comment:
Why is the `Set` returned by `getAllEndpoints` encapsulated in another `Set`? Can we just iterate `getAllEndpoints`? Also wondering whether we could replace the entire method body by `Multimaps.index(getAllEndpoints(), snitch::getDatacenter)`.
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,20 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
We could evaluate the `useStrictConsistency && tokens != null` part of the boolean expression at the beginning of the method, so in some cases wouldn't need to compute `nodes`. Alternatively, we could encapsulate the current calculation of `nodes` in a function, so it would be lazily called from the boolean expression.
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +59,9 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
Review comment:
Nit: misaligned
```suggestion
if (ClientWarn.instance.get() == null)
ClientWarn.instance.captureWarnings();
```
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
Review comment:
Nice test :). Don't we need a call to `requireNetwork()` to make the client warnings work when the test is run isolated?
##########
File path: src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
##########
@@ -51,7 +51,6 @@
{
private static final Logger logger = LoggerFactory.getLogger(AbstractReplicationStrategy.class);
- @VisibleForTesting
Review comment:
I think `keyspaceName` could be protected
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r567577707
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
Review comment:
There are other tests checking warnings without it and passing. But I noticed `ant jar test -Dtest.name=CreateTest -Dtest.methods=testCreateKeyspaceRFgtNodesWarns` & variation runs all tests or none, seems broken Did you manage to run it in isolation?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571900160
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
ok, so maybe I was not precise, feel free to ignore:
if we have: NTS witrh RF = {DC1:3, DC2: 3} and we have cluster with N(DC1)=2, N(DC2)=6 then
- nodes will be 8?
- so res will be True?
What is bit misleading in your explanation:
> not 6 bc one dc is not replicating
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574238101
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
If we don't extract to numWarnings function, I think we need to change the naming a bit.
Size of warnings is better to be changed by num/number. Proposal:
`previousNumWarnings` and `newNumWarnings`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573439927
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
PS I also didn't manage to reproduce the failure locally
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r570744774
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
If you run:
- Test class + no `requireNetwrok()`: pass
- Test class + `requireNetwrok()`: fail unless you sleep
- Test method + no `requireNetwrok()`: fail bc test sees 0 nodes and we short circuit that
- Test method + `requireNetwrok()`: pass
The problem being warnings goes to null as they get 'cleared'.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573762270
##########
File path: test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java
##########
@@ -72,7 +69,7 @@ public void testCreateKeyspaceTableWarning() throws IOException
try (SimpleClient client = newSimpleClient(ProtocolVersion.CURRENT).connect(false))
{
- String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'2'}";
+ String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'1'}";
Review comment:
I'd argue the test was having RF:2 erroneously. Would you agree or you prefer I alter the asserts?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574275745
##########
File path: src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
##########
@@ -302,6 +310,36 @@ public void validateOptions() throws ConfigurationException
}
}
+ @Override
+ public void maybeWarnOnOptions()
+ {
+ if (!SchemaConstants.isSystemKeyspace(keyspaceName))
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dcsNodes = StorageService.instance.getTokenMetadata()
+ .getDC2AllEndpoints(snitch);
+ for (Entry<String, String> e : this.configOptions.entrySet())
+ {
+
+ String dc = e.getKey();
+ ReplicationFactor rf = getReplicationFactor(dc);
+ int nodeCount = dcsNodes.get(dc).size();
+ // nodeCount==0 on many tests
Review comment:
Btw that is why we require `requireNetwork()` on the newly added test in `AlterTest`. Otherwise the test sees 0 nodes and no warnings are generated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574232389
##########
File path: src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
##########
@@ -302,6 +310,36 @@ public void validateOptions() throws ConfigurationException
}
}
+ @Override
+ public void maybeWarnOnOptions()
+ {
+ if (!SchemaConstants.isSystemKeyspace(keyspaceName))
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dcsNodes = StorageService.instance.getTokenMetadata()
+ .getDC2AllEndpoints(snitch);
+ for (Entry<String, String> e : this.configOptions.entrySet())
+ {
+
+ String dc = e.getKey();
+ ReplicationFactor rf = getReplicationFactor(dc);
+ int nodeCount = dcsNodes.get(dc).size();
+ // nodeCount==0 on many tests
Review comment:
Can you explain, please?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574266219
##########
File path: src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
##########
@@ -302,6 +310,36 @@ public void validateOptions() throws ConfigurationException
}
}
+ @Override
+ public void maybeWarnOnOptions()
+ {
+ if (!SchemaConstants.isSystemKeyspace(keyspaceName))
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dcsNodes = StorageService.instance.getTokenMetadata()
+ .getDC2AllEndpoints(snitch);
+ for (Entry<String, String> e : this.configOptions.entrySet())
+ {
+
+ String dc = e.getKey();
+ ReplicationFactor rf = getReplicationFactor(dc);
+ int nodeCount = dcsNodes.get(dc).size();
+ // nodeCount==0 on many tests
Review comment:
Tests that don't set up a complete cluster with network, gossip, etc will return the number of available nodes as '0', which makes sense but only for a testing env where things are half-baked.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r572716115
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
up to you... best solution would be polling wait for zero.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r572717297
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
But to be honest: `sleep` is one of the most popular ways of introducing flickering in the tests.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773256210
> We'd need a dtest run <4.0 for the newly added dtest. Maybe you can fire that easily on jenkins rather than going through the circle pain?
Running dtests on Jenkins:
* [cassandra-2.2](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/366/)
* [cassandra-3.0](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/367/)
* [cassandra-3.11](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/368/)
* [trunk](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/369/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng closed pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng closed pull request #870:
URL: https://github.com/apache/cassandra/pull/870
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573474592
##########
File path: test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java
##########
@@ -72,7 +69,7 @@ public void testCreateKeyspaceTableWarning() throws IOException
try (SimpleClient client = newSimpleClient(ProtocolVersion.CURRENT).connect(false))
{
- String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'2'}";
+ String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'1'}";
Review comment:
I'd say yes, bc otherwise you get the `RF>N` extra warnings that make the test fail.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r568576743
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dc2Nodes = metadata.getDC2AllEndpoints(snitch);
+
+ NetworkTopologyStrategy ntps = (NetworkTopologyStrategy) strat;
+ for (String dc : dc2Nodes.keySet())
+ nodes += ntps.getReplicationFactor(dc).allReplicas > 0 ? dc2Nodes.get(dc).size() : 0;
+ }
+ else
+ nodes = metadata.getSizeOfAllEndpoints();
+
+ res = res && nodes > strat.getReplicationFactor().allReplicas;
Review comment:
Since the function is not in the hot path I'd prefer readability (if the the early return is more readable, which is debatable), but I'm not against the current approach if you prefer it.
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
Review comment:
That makes sense, +1
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-774020406
> Pushed latest review comments. Also the dtests runs for previous versions lgtm to my untrained eye on previous versions runs. Wdyt @adelapena ?
Since we are only modifying trunk, I think the only dtest suitable to fail on previous branches due to the changes is the new `test_rf_gt_nodes_multidc_should_succeed`, and it seems it passes.
> Would you be so kind again to run a full QA run on jenkins so we get some clear data please?
Sure, running: https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch/367/
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r570744774
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
If you run:
- Test class + no `requireNetwrok()`: pass
- Test class + `requireNetwrok()`: fail unless you sleep
- Test method + no `requireNetwrok()`: fail bc test sees 0 nodes and we short circuit that
- Test method + `requireNetwrok()`: pass
The problem being warnings goes to null as they get 'cleared' unless you sleep.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r570300307
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
I haven't been able to reproduce this. Is it the problem that the warnings are `null` if `requireNetwork` hasn't finished, or that there are other previous contents in them?
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
Nit: maybe we could name this using the `warnings` word, something like `previousNumWarnings`, or `previousWarningsSize`? Feel free to ignore if you don't agree.
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
+
+ // NTS
+ ClientWarn.instance.captureWarnings();
+ execute("CREATE KEYSPACE testABC WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 3 }");
Review comment:
Not a big deal, but we could use [`CQLTester#createKeyspace`](https://github.com/apache/cassandra/blob/trunk/test/unit/org/apache/cassandra/cql3/CQLTester.java#L692) instead of `execute`, as it's done [here](https://github.com/adelapena/cassandra/commit/a42317a0e3ccf5d291b6629ee0c318298dcb994c) as an example.
The advantage of `createKeyspace` is that it reduces the likelihood of collisions with other tests using the same keyspace names (IIRC we have had problems with this in the past). Also, `CQLTester` conditionally [drops the keyspaces](https://github.com/apache/cassandra/blob/trunk/test/unit/org/apache/cassandra/cql3/CQLTester.java#L344) created with `createKeyspace` after each test, so we wouldn't need the `DROP KEYSPACE` queries at the end of this tests. These drops will be executed even if the test fails, as if they were in a `finally` block, which is also an advantage.
##########
File path: src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
##########
@@ -299,6 +298,8 @@ public RangesAtEndpoint getPendingAddressRanges(TokenMetadata metadata, Collecti
public abstract void validateOptions() throws ConfigurationException;
+ public abstract void maybeWarnOnOptions() throws ConfigurationException;
Review comment:
Since the purpose of the method is just warn about stuff I guess it won't raise `ConfigurationException`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571853059
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
maybe we can introduce `ClientWarn::numWarnings()` method that would hide this null check and return 0 or size?
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +62,10 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
`numWarnings()` could be used here
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -75,8 +85,16 @@ public Keyspaces apply(Keyspaces schema)
throw ire("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
keyspace.params.validate(keyspaceName);
+ Keyspaces ksps = schema.withAddedOrUpdated(keyspace);
- return schema.withAddedOrUpdated(keyspace);
+ if (ClientWarn.instance.getWarnings() != null)
Review comment:
and here same pattern: `clientWanrings.addAll(ClientWarn.instance.getWarningsAfter(previousWarningsSize));`
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,59 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
+
+ // NTS
+ ClientWarn.instance.captureWarnings();
+ String ks = createKeyspace("CREATE KEYSPACE %s WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 3 }");
+ List<String> warnings = ClientWarn.instance.getWarnings();
+ assertEquals(1, warnings.size());
+ Assertions.assertThat(warnings.get(0)).contains("Your replication factor 3 for keyspace " + ks + " is higher than the number of nodes 1 for datacenter " + DATA_CENTER);
+
+ ClientWarn.instance.captureWarnings();
+ execute("CREATE TABLE " + ks + ".t (k int PRIMARY KEY, v int)");
+ warnings = ClientWarn.instance.getWarnings();
+ assertNull(warnings);
+
+ ClientWarn.instance.captureWarnings();
Review comment:
with so many cases maybe we can extract some methods
```
private void expectCreateKeyspaceWarning(ddl, warning)
{
List<String> warnings = ClientWarn.instance.getWarnings();
createKeyspace(ddl);
assertEquals(1, warnings.size());
Assertions.assertThat(warnings.get(0)).contains(warning);
}
```
and
```
private void expectNoWarning(...)
```
so that test would become a list of checks?
```
expectWarning(...)
expectNoWarning(....)
```
##########
File path: src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
##########
@@ -302,6 +310,34 @@ public void validateOptions() throws ConfigurationException
}
}
+ @Override
+ public void maybeWarnOnOptions()
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dcsNodes = StorageService.instance.getTokenMetadata().getDC2AllEndpoints(snitch);
+ for (Entry<String, String> e : this.configOptions.entrySet())
+ {
+ if (!SchemaConstants.isSystemKeyspace(keyspaceName))
Review comment:
I think this system keyspace check should be outside of the loop, as int he loop it is causing reader to think why.
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
Sorry, I am not sure what the conditions should be, just to make sure:
DC1:3, DC2:3 with DC1 having 2 and DC2 having 6 nodes => res = True?
Also the condition before change was `!=` and now it is `>`?
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -78,7 +82,14 @@ public Keyspaces apply(Keyspaces schema)
validateNoRangeMovements();
validateTransientReplication(keyspace.createReplicationStrategy(), newKeyspace.createReplicationStrategy());
- return schema.withAddedOrUpdated(newKeyspace);
+ Keyspaces res = schema.withAddedOrUpdated(newKeyspace);
+ if (ClientWarn.instance.getWarnings() != null)
Review comment:
with proposed earlier method this will be easier:
```
int newSize = ClientWarn.instance.numWarnings();
if (newSize > previousWarningSize)
{
clientWarnings.addAll(...)
}
```
but even better it can all be probably extraceted into some new `ClientWarn` method,
that would return "getWarningsAfter(previousWarningSize)" and return some list or empty list
depending on the conditions.
Then this code would become simply:
```
clientWarnings.addAll(ClientWarn.instance.getWarningsAfter(previousWarningSize));
```
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
so in this case maybe we should
- poll until warnings are cleared, or
- assert that warnings are cleared after this sleep.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r567806318
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dc2Nodes = metadata.getDC2AllEndpoints(snitch);
+
+ NetworkTopologyStrategy ntps = (NetworkTopologyStrategy) strat;
+ for (String dc : dc2Nodes.keySet())
+ nodes += ntps.getReplicationFactor(dc).allReplicas > 0 ? dc2Nodes.get(dc).size() : 0;
+ }
+ else
+ nodes = metadata.getSizeOfAllEndpoints();
+
+ res = res && nodes > strat.getReplicationFactor().allReplicas;
Review comment:
The `&&` part seems redundant here, since `res` is always true when evaluating this line, as it's shown by an IDE warning. We could just use:
```java
res = nodes > strat.getReplicationFactor().allReplicas;
```
Or maybe we could just eagerly return `false` after evaluating `useStrictConsistency` and `token` at the beginning of the method, and so also reduce nesting?
```java
if (!useStrictConsistency || tokens == null)
return false;
int nodes = 0;
if (strat instanceof NetworkTopologyStrategy)
{
ImmutableMultimap<String, InetAddressAndPort> dc2Nodes = metadata.getDC2AllEndpoints(snitch);
NetworkTopologyStrategy ntps = (NetworkTopologyStrategy) strat;
for (String dc : dc2Nodes.keySet())
nodes += ntps.getReplicationFactor(dc).allReplicas > 0 ? dc2Nodes.get(dc).size() : 0;
}
else
{
nodes = metadata.getSizeOfAllEndpoints();
}
return nodes > strat.getReplicationFactor().allReplicas;
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574236972
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +62,10 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
My previous comment in AlterKeyspaceStatement stays - let's then change a bit the naming. Thanks :-)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-774949642
Ok the latest run is more reasonable and all failures pass locally
- Ci [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/212/workflows/efd048e3-51db-4b5f-913b-1a1a7d55d208)
- CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/212/workflows/660ecbbc-6f8c-4812-a527-c77897e41243)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571892316
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,59 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
+
+ // NTS
+ ClientWarn.instance.captureWarnings();
+ String ks = createKeyspace("CREATE KEYSPACE %s WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 3 }");
+ List<String> warnings = ClientWarn.instance.getWarnings();
+ assertEquals(1, warnings.size());
+ Assertions.assertThat(warnings.get(0)).contains("Your replication factor 3 for keyspace " + ks + " is higher than the number of nodes 1 for datacenter " + DATA_CENTER);
+
+ ClientWarn.instance.captureWarnings();
+ execute("CREATE TABLE " + ks + ".t (k int PRIMARY KEY, v int)");
+ warnings = ClientWarn.instance.getWarnings();
+ assertNull(warnings);
+
+ ClientWarn.instance.captureWarnings();
Review comment:
+1 if it were a test class wide util, but being a small and single method... meh I see it as a nit imo.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773830701
Pushed latest review comments. Also the dtests runs for previous versions lgtm to _my untrained eye_ on previous versions runs. Wdyt @adelapena ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r570744774
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
If you run:
- Test class + no `requireNetwrok()`: pass
- Test class + `requireNetwrok()`: fail unless you sleep
- Test method + no `requireNetwrok()`: fail bc test sees 0 nodes and we short circuit that
- Test method + `requireNetwrok()`: pass
The problem being warnings goes to null as they get 'cleared'.
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
If you run:
- Test class + no `requireNetwrok()`: pass
- Test class + `requireNetwrok()`: fail unless you sleep
- Test method + no `requireNetwrok()`: fail bc test sees 0 nodes and we short circuit that
- Test method + `requireNetwrok()`: pass
The problem being warnings goes to null as they get 'cleared' unless you sleep.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773256210
> We'd need a dtest run <4.0 for the newly added dtest. Maybe you can fire that easily on jenkins rather than going through the circle pain?
Running dtests on Jenkins:
* [cassandra-2.2](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/366/)
* [cassandra-3.0](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/367/)
* [cassandra-3.11](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/368/)
* [trunk](https://ci-cassandra.apache.org/view/all/job/Cassandra-devbranch-dtest/369/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r568576743
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dc2Nodes = metadata.getDC2AllEndpoints(snitch);
+
+ NetworkTopologyStrategy ntps = (NetworkTopologyStrategy) strat;
+ for (String dc : dc2Nodes.keySet())
+ nodes += ntps.getReplicationFactor(dc).allReplicas > 0 ? dc2Nodes.get(dc).size() : 0;
+ }
+ else
+ nodes = metadata.getSizeOfAllEndpoints();
+
+ res = res && nodes > strat.getReplicationFactor().allReplicas;
Review comment:
Since the function is not in the hot path I'd prefer readability (if the the early return is more readable, which is debatable), but I'm not against the current approach if you prefer it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573476760
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +62,10 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
I am -1 bc it would break the semantics of a non-inited `ClientWarn` instance being non functional until now. If we do that change some methods will fail and others will work when the instance is not inited. In any case I have no hard opinion here. I can do it if you guys prefer it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571894188
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
well, the difference is for a person debugging the failures:
"expected 0 warnings at the start of the test"
vs
"1 was expected and got 2"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571891628
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
The test already asserts there is only 1 warn and that's the right one correct?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r567578756
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,20 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
I like that but I would spare creating a new function.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r570300307
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
I haven't been able to reproduce this. Is it the problem that the warnings are `null` if `requireNetwork` hasn't finished, or that there are other previous contents in them?
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
Nit: maybe we could name this using the `warnings` word, something like `previousNumWarnings`, or `previousWarningsSize`? Feel free to ignore if you don't agree.
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
+
+ // NTS
+ ClientWarn.instance.captureWarnings();
+ execute("CREATE KEYSPACE testABC WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 3 }");
Review comment:
Not a big deal, but we could use [`CQLTester#createKeyspace`](https://github.com/apache/cassandra/blob/trunk/test/unit/org/apache/cassandra/cql3/CQLTester.java#L692) instead of `execute`, as it's done [here](https://github.com/adelapena/cassandra/commit/a42317a0e3ccf5d291b6629ee0c318298dcb994c) as an example.
The advantage of `createKeyspace` is that it reduces the likelihood of collisions with other tests using the same keyspace names (IIRC we have had problems with this in the past). Also, `CQLTester` conditionally [drops the keyspaces](https://github.com/apache/cassandra/blob/trunk/test/unit/org/apache/cassandra/cql3/CQLTester.java#L344) created with `createKeyspace` after each test, so we wouldn't need the `DROP KEYSPACE` queries at the end of this tests. These drops will be executed even if the test fails, as if they were in a `finally` block, which is also an advantage.
##########
File path: src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
##########
@@ -299,6 +298,8 @@ public RangesAtEndpoint getPendingAddressRanges(TokenMetadata metadata, Collecti
public abstract void validateOptions() throws ConfigurationException;
+ public abstract void maybeWarnOnOptions() throws ConfigurationException;
Review comment:
Since the purpose of the method is just warn about stuff I guess it won't raise `ConfigurationException`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571900593
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +62,10 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
Will resolve depending on how we resolve the above. Resolving for now to keep this clear-ish
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -75,8 +85,16 @@ public Keyspaces apply(Keyspaces schema)
throw ire("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
keyspace.params.validate(keyspaceName);
+ Keyspaces ksps = schema.withAddedOrUpdated(keyspace);
- return schema.withAddedOrUpdated(keyspace);
+ if (ClientWarn.instance.getWarnings() != null)
Review comment:
Will resolve depending on how we resolve the above. Resolving for now to keep this clear-ish
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571898892
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
Yeah on the other hand you can argue you're loosing the semantics on a non-inited `ClientWarn` instance returning `0` instead of NPE-ing... :shrug: I'd say this is a nit? I am weary of touching such a class for such a specific usage and a nit :shrug:
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573476760
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +62,10 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
I am -1 bc it would break the semantics of a non-inited `ClientWarn` instance being non functional until now. If we do that change some methods will fail and others will work when not the instance is not inited. In any case I have no hard opinion here. I can do it if you guys prefer it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-774913119
So circle vs devbranch vs nightly failures don't seem to match so I am at a loss. But:
- I will run circle again and see if I can get a more stable run
- Devbranch seems to be failing on tests that also fail locally for trunk. So I guess devbranch also has 'known offenders'. I'd need @adelapena to confirm if he sees anything suspicious
- I think that if circle and nightlies mostly match we should be ok
Waiting for CI results
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573750635
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -17,7 +17,14 @@
*/
package org.apache.cassandra.dht;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
Review comment:
I am confused, marked as resolved but the import is still here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r572884430
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
Polling seems like a good way to avoid the test becoming flaky. However, I'm still unable to reproduce the failure when the current wait is absent. I have removed the wait [here](https://github.com/adelapena/cassandra/commits/CASSANDRA-16296-review-3) and run both the individual test and the entire suite/class in the multiplexer:
* [method](https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/690/)
* [class](https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/691/)
It's 100 runs for the class and 200 runs for the method, without any failure. Running them locally a few dozen times doesn't produce any failure either.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r568577330
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
Review comment:
That makes sense, +1
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574275407
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -56,6 +62,10 @@ public CreateKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs, bo
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
Added `numWarnings()`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573759185
##########
File path: test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java
##########
@@ -72,7 +69,7 @@ public void testCreateKeyspaceTableWarning() throws IOException
try (SimpleClient client = newSimpleClient(ProtocolVersion.CURRENT).connect(false))
{
- String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'2'}";
+ String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'1'}";
Review comment:
Then why don't we just change the assertions around the warnings? So we don't change the idea of the test but assert on the right flow - like 1 warning and it is that specific one and not others
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r564442977
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,20 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
We could add a `getReplicationFactor(dc)` to `SimpleStrategy` to collapse this further thx to inheritance. But that would mean `SimpleStrategy.getReplicationFactor(dc)` would have to compare the dc strings to match. That would go against `AbstractReplicationStrategy.getReplicationFactor()` notes stating this should be FAST. The extra string comparison is the problem so I opted for this solution. Happy to discuss.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng edited a comment on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng edited a comment on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773215704
@adelapena I think the latest commit solves the sticky warning. I also expanded the unit test to more cases and added ALTER to it. Same on the dtest.
- CI [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/209/workflows/1b6a3737-d412-4fca-8953-6c02ba3dcb22)
- CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/209/workflows/8f097f51-72c3-452e-9b3a-b403f47e76da)
LGTM: Known offenders or pass locally.
We'd need a dtest run <4.0 for the newly added dtest. Maybe you can fire that easily on jenkins rather than going through the circle pain?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng edited a comment on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng edited a comment on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773215704
@adelapena I think the latest commit solves the sticky warning. I also expanded the unit test to more cases and added ALTER to it. Same on the dtest.
- CI [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/209/workflows/1b6a3737-d412-4fca-8953-6c02ba3dcb22)
- CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/209/workflows/8f097f51-72c3-452e-9b3a-b403f47e76da)
LGTM: Known offenders or pass locally.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574270782
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
> doesn't have to be for !warns.emptybut for whatever signals that requireNetwork has finished
That is _exactly_ the point I was trying to make. Thx for summarizing it. I am happy to either remove the Sleep or leave it. You guys let me know what you prefer.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r568326365
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dc2Nodes = metadata.getDC2AllEndpoints(snitch);
+
+ NetworkTopologyStrategy ntps = (NetworkTopologyStrategy) strat;
+ for (String dc : dc2Nodes.keySet())
+ nodes += ntps.getReplicationFactor(dc).allReplicas > 0 ? dc2Nodes.get(dc).size() : 0;
+ }
+ else
+ nodes = metadata.getSizeOfAllEndpoints();
+
+ res = res && nodes > strat.getReplicationFactor().allReplicas;
Review comment:
I was thinking about branch prediction when writing that. Iirc from some training an early return disables it so accumulating the result to return at the end is preferable. You'd then want to keep `nodes` declaration inside the branch to spare that cost when possible as well.
So I am removing the `res &&` bit indeed but the rest sgtm. Does it make sense or am I being too far reached? This is not in the hot path iiuc so we may want to favor readability :thinking:
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
Review comment:
Ok found it. Without the network the test sees 0 nodes and that has been short circuited. With the network we see the node and then the test passes. As the other tests don't rely on the number of nodes to generate a warning they pass without the network. Also I was using `test` instead of `testsome` ops!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r568326365
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dc2Nodes = metadata.getDC2AllEndpoints(snitch);
+
+ NetworkTopologyStrategy ntps = (NetworkTopologyStrategy) strat;
+ for (String dc : dc2Nodes.keySet())
+ nodes += ntps.getReplicationFactor(dc).allReplicas > 0 ? dc2Nodes.get(dc).size() : 0;
+ }
+ else
+ nodes = metadata.getSizeOfAllEndpoints();
+
+ res = res && nodes > strat.getReplicationFactor().allReplicas;
Review comment:
I was thinking about branch prediction when writing that. Iirc from some training an early return disables it so accumulating the result to return at the end is preferable. You'd then want to keep `nodes` declaration inside the branch to spare that cost when possible as well.
So I am removing the `res &&` bit indeed but the rest sgtm. Does it make sense or am I being too far reached? This is not in the hot path iiuc so we may want to favor readability :thinking:
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-777283675
CI [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/214/workflows/72274821-ae12-4e27-b6fd-200ced9e3ae8)
CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/214/workflows/1502bc7a-877d-441f-99e8-f172959fe7df)
CI LGTM
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574054070
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
> Thx Andres for multiplexing it but running the method individually won't repro the issue. I get it, sometimes, only if running the whole class. It failed only 1 out of 20 for me today whereas it used to fail every time some days ago...
The jobs above also include [100 runs](https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/691/) for the whole class. [Here](https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/692/) and [here](https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/693/) are two more runs of the whole class with 200 repetitions each. That totals 500 runs of the whole class without a single failure, so I'd say that definitely we can't reproduce it with the multiplexer.
Unfortunately testing this with CircleCI is not that easy, but I have seen a few full unit tests runs that pass without the sleep:
* https://app.circleci.com/pipelines/github/adelapena/cassandra/175/workflows/3432945a-05bc-40b4-93cf-607b1ce6566c/jobs/1291
* https://app.circleci.com/pipelines/github/adelapena/cassandra/175/workflows/4a879181-921a-47bf-8cd3-a886fbb99fa7/jobs/1297
* https://app.circleci.com/pipelines/github/adelapena/cassandra/175/workflows/a39779a1-e059-4d5c-9563-3de78d9bd864/jobs/1303
* https://app.circleci.com/pipelines/github/adelapena/cassandra/175/workflows/544a5037-0261-49d0-b5c1-9dfdfac09bc5/jobs/1311
* https://app.circleci.com/pipelines/github/adelapena/cassandra/175/workflows/1c58b779-7d80-4e79-b7d7-1b73aecc62b8/jobs/1314
I guess that the (in)famous poll, if needed, doesn't have to be for `!warns.empty` but for whatever signals that `requireNetwork` has finished and therefore it's safe to use. Said that, if we still think that the test can fail without the wait and we don't want to spend more time investigating what's the condition that signals the finalization of `requireNetwork` I think I can live with the current sleep.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-762165919
CI [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/190/workflows/1aec1b7b-d977-456f-9aac-8b874f8d431b)
CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/190/workflows/a3899559-3e48-45d1-a4b3-68df60c6b0e5)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571890058
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
I am not following your explanation sorry.
In any case notice we're comparing the number of _replicating nodes_ (not nodes, but replicating nodes only) to the RF. So if you have 6 nodes but only 3 are _replicas_ you should behave as if there were only 3 nodes towards the RF, not 6 bc one dc is _not_ replicating i.e. Does it help?
Yep method doc also points towards `>` which makes sense to me. Idk why it was `!=`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573472792
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
Hi,
Thx Andres for multiplexing it but running the method individually won't repro the issue. I get it, sometimes, only if running the whole class. It failed only 1 out of 20 for me today whereas it used to fail every time some days ago...
As I am failing to explain why the polling is wrong let me try to show it with code assuming `while(warns not empty) sleep(1)`;
- Test method starts and 'requireNetwork()' is called
- Polling loop sees 0 warns so doesn't sleep
- Test runs CQL and a warning is generated
- Some 'requireNetwork' async call clears warnings
- Assert fails as it sees 0 warnings instead of 1
Now we do the same without polling
- Test method starts and 'requireNetwork()' is called
- Sleep(1) + some 'requireNetwork' async call clears warnings hopefully within the sleep. This is the source of flakiness
- Test runs CQL and a warning is generated
- Assert succeeds
The problem is that waiting for warns to be empty is _not_ what we need. We need to wait for warns to be stable (aka requireNetwork to have finished completely). Now you can tell me I should do instead a `do sleep(1) while(!warns.empty())` and then it will work. But what's the point in polling on a random variable? It's like polling for pears when you're waiting on apples. It's the sleep that makes things work, the poll does nothing but confuse the reader imo.
This is the best I can explain it. If I am not managing to explain it let's just remove or poll (any of both won't sleep) and then we can fix it when/if it starts failing in CI.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571932755
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
Ok icwym now. You were talking DC:RF and DC:N on each side. Yes, nodes would be 8. And on DC1 you'd get a warning bd RF=3 but N=2.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-771450797
CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/206/workflows/7920afca-6e11-4360-ad1b-dd8485a6d5f3): LGTM, unrelated or passes locally
Ci [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/206/workflows/ae60d3e0-05af-45d5-b1a9-9fd38dc48308): LGTM
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573759185
##########
File path: test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java
##########
@@ -72,7 +69,7 @@ public void testCreateKeyspaceTableWarning() throws IOException
try (SimpleClient client = newSimpleClient(ProtocolVersion.CURRENT).connect(false))
{
- String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'2'}";
+ String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'1'}";
Review comment:
Then why don't we just change the assertions around the warnings? So we don't change the idea of the test but assert on the right flow - like 1 warning and it is that specific one
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng edited a comment on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng edited a comment on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-762165919
CI [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/190/workflows/1aec1b7b-d977-456f-9aac-8b874f8d431b)
CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/190/workflows/a3899559-3e48-45d1-a4b3-68df60c6b0e5)
Failures seem unrelated and they all pass locally. Some are even know offenders such as CASTest
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571909262
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
up to you
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-771450797
CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/206/workflows/7920afca-6e11-4360-ad1b-dd8485a6d5f3): LGTM, unrelated or passes locally
Ci [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/206/workflows/ae60d3e0-05af-45d5-b1a9-9fd38dc48308): LGTM
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r566935391
##########
File path: test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java
##########
@@ -81,7 +80,10 @@ public void testCreateKeyspaceTableWarning() throws IOException
DatabaseDescriptor.setKeyspaceCountWarnThreshold(Schema.instance.getKeyspaces().size() + 1);
query = new QueryMessage(String.format(createKeyspace, 2), QueryOptions.DEFAULT);
resp = client.execute(query);
- assertTrue(resp.getWarnings() == null || resp.getWarnings().isEmpty());
+ List<String> warns = resp.getWarnings();
+ if (warns != null)
+ warns.removeIf(s -> s.contains("is higher than the number of nodes"));
Review comment:
I understand that we still have warnings here despite of having a RF=1 because of the RF of `system_distributed` and `system_traces`. Indeed, when we run a single instance we always have warnings for those in the logs. I'm wondering whether it would make sense to not emit the warning for system keyspaces.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r567580982
##########
File path: src/java/org/apache/cassandra/locator/TokenMetadata.java
##########
@@ -1331,6 +1331,23 @@ public EndpointsForToken getWriteEndpoints(Token token, String keyspaceName, End
}
}
+ /**
+ * @return a (stable copy, won't be modified) datacenter to Endpoint map for all the nodes in the cluster.
+ */
+ public ImmutableMultimap<String, InetAddressAndPort> getDC2AllEndpoints(IEndpointSnitch snitch)
+ {
+ ImmutableMultimap.Builder<String, InetAddressAndPort> dc2Nodesbuilder = ImmutableMultimap.builder();
+ HashSet<InetAddressAndPort> nodes = new HashSet<InetAddressAndPort>(getAllEndpoints());
Review comment:
+1
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r568334795
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -365,6 +372,31 @@ public void testKeyspace() throws Throwable
execute("DROP KEYSPACE testXYZ");
}
+ /**
+ * Test a warning is thrown on create keyspace with a RF > number of nodes.
+ */
+ @Test
+ public void testCreateKeyspaceRFgtNodesWarns() throws Throwable
Review comment:
Ok found it. Without the network the test sees 0 nodes and that has been short circuited. With the network we see the node and then the test passes. As the other tests don't rely on the number of nodes to generate a warning they pass without the network. Also I was using `test` instead of `testsome` ops!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571893503
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,59 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
+
+ // NTS
+ ClientWarn.instance.captureWarnings();
+ String ks = createKeyspace("CREATE KEYSPACE %s WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 3 }");
+ List<String> warnings = ClientWarn.instance.getWarnings();
+ assertEquals(1, warnings.size());
+ Assertions.assertThat(warnings.get(0)).contains("Your replication factor 3 for keyspace " + ks + " is higher than the number of nodes 1 for datacenter " + DATA_CENTER);
+
+ ClientWarn.instance.captureWarnings();
+ execute("CREATE TABLE " + ks + ".t (k int PRIMARY KEY, v int)");
+ warnings = ClientWarn.instance.getWarnings();
+ assertNull(warnings);
+
+ ClientWarn.instance.captureWarnings();
Review comment:
up to you
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574238101
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
I think we need to change the naming a bit.
Size of warnings is better to be changed by num/number. Proposal:
`previousNumWarnings` and `newNumWarnings`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-776432142
I left some small questions/comments, I want to test a bit more tomorrow
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571891628
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
The test already asserts there is only 1 warn and that's the right one correct?
Edit: forgot about the poll. Warnings being clear doesn't mean `requireNetwrok()` completed right? They could be clear for a number of reasons. What we need are non async test framework methods (food for another ticket imo)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571909003
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -78,7 +82,14 @@ public Keyspaces apply(Keyspaces schema)
validateNoRangeMovements();
validateTransientReplication(keyspace.createReplicationStrategy(), newKeyspace.createReplicationStrategy());
- return schema.withAddedOrUpdated(newKeyspace);
+ Keyspaces res = schema.withAddedOrUpdated(newKeyspace);
+ if (ClientWarn.instance.getWarnings() != null)
Review comment:
fine
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571922257
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -62,6 +63,9 @@ public AlterKeyspaceStatement(String keyspaceName, KeyspaceAttributes attrs)
public Keyspaces apply(Keyspaces schema)
{
+ if (ClientWarn.instance.get() == null)
+ ClientWarn.instance.captureWarnings();
+ int previousWarningsSize = ClientWarn.instance.getWarnings() == null ? 0 : ClientWarn.instance.getWarnings().size();
Review comment:
logic would not be lost:
```
int previousWarningsSize = ClientWarn.instance.numWarnings();
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] ekaterinadimitrova2 commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
ekaterinadimitrova2 commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r574235644
##########
File path: test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java
##########
@@ -72,7 +69,7 @@ public void testCreateKeyspaceTableWarning() throws IOException
try (SimpleClient client = newSimpleClient(ProtocolVersion.CURRENT).connect(false))
{
- String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'2'}";
+ String createKeyspace = "CREATE KEYSPACE createkswarning%d WITH REPLICATION={'class':'org.apache.cassandra.locator.NetworkTopologyStrategy','datacenter1':'1'}";
Review comment:
I prefer not to change it and to show just the newly added warnings and changed behavior.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] adelapena commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573649242
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java
##########
@@ -75,8 +85,16 @@ public Keyspaces apply(Keyspaces schema)
throw ire("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
keyspace.params.validate(keyspaceName);
+ Keyspaces ksps = schema.withAddedOrUpdated(keyspace);
Review comment:
I would also prefer `keyspaces` instead on `ksps`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773215704
@adelapena I think the latest commit solves the sticky warning. I also expanded the unit test to more cases and added ALTER to it. Same on the dtest.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-778973509
Squashed
- CI [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/216/workflows/f479b643-7503-4d2d-adca-74ad048c7bed)
- CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/216/workflows/9b0a1a6a-0dda-41b5-a52a-5e75b5b8e911)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-767484714
- CI [j11](https://app.circleci.com/pipelines/github/bereng/cassandra/198/workflows/fe4619b8-072b-4e8f-bb0f-b129059ba115)
All good
- CI [j8](https://app.circleci.com/pipelines/github/bereng/cassandra/198/workflows/53624615-b928-4d56-8612-4d8f14c16639)
Known dtest failures + a seemingly unrelated failure that passes locally
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773215704
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571896048
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java
##########
@@ -78,7 +82,14 @@ public Keyspaces apply(Keyspaces schema)
validateNoRangeMovements();
validateTransientReplication(keyspace.createReplicationStrategy(), newKeyspace.createReplicationStrategy());
- return schema.withAddedOrUpdated(newKeyspace);
+ Keyspaces res = schema.withAddedOrUpdated(newKeyspace);
+ if (ClientWarn.instance.getWarnings() != null)
Review comment:
I think this case is not a candidate to be generalized into the `ClientWarn`class. The problem comes from the underlying ThreadLocal and the many execution paths. Some execute on the same thread while others on a pool where that thread is not deterministic. Some will contain previous warnings and others don't. That's why some warnings accumulate and others clear. But that is particular to this specific scenario, hence the `clientWarnings()` on the API to pull warnings across threads. So I wouldn't generalize it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r572736795
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
It is indeed. It is an anti-pattern but still a workaround until the async behavior is fixed. Polling is plain wrong imo which is worst I would say. We have 2 bad options and we need to choose one :man_shrugging:
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573763206
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -17,7 +17,14 @@
*/
package org.apache.cassandra.dht;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
Review comment:
I changed the code locally but haven't pushed yet. I'm waiting for other 2 loose ends to resolve and then I push everything.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng edited a comment on pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng edited a comment on pull request #870:
URL: https://github.com/apache/cassandra/pull/870#issuecomment-773215704
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r572602851
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
I disagree here. A person debugging the test will be under the impression the poll guarantees the 0 warnings which is not true. A sleep signals a _best effort_ to workaround an async issue as in other tests. The 'expected 0 warnings at the start of the test' is implicit in the assert expecting only 1 warning.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571900160
##########
File path: src/java/org/apache/cassandra/dht/RangeStreamer.java
##########
@@ -353,9 +361,27 @@ public void addRanges(String keyspaceName, ReplicaCollection<?> replicas)
*/
private boolean useStrictSourcesForRanges(AbstractReplicationStrategy strat)
{
- return useStrictConsistency
- && tokens != null
- && metadata.getSizeOfAllEndpoints() != strat.getReplicationFactor().allReplicas;
+ boolean res = useStrictConsistency && tokens != null;
+
+ if (res)
+ {
+ int nodes = 0;
+
+ if (strat instanceof NetworkTopologyStrategy)
Review comment:
ok, so maybe I was not precise, feel free to ignore:
if we have: NTS witrh RF = {DC1:3, DC2: 3} and we have cluster with N(DC1)=2, N(DC2)=6 then
- nodes will be 8?
- so res will be True?
I think it fits the description "nodes in the cluster is > # of replicas". I just wanted to make sure.
What is bit misleading in your explanation:
> not 6 bc one dc is not replicating
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] bereng commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571902056
##########
File path: src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
##########
@@ -302,6 +310,34 @@ public void validateOptions() throws ConfigurationException
}
}
+ @Override
+ public void maybeWarnOnOptions()
+ {
+ ImmutableMultimap<String, InetAddressAndPort> dcsNodes = StorageService.instance.getTokenMetadata().getDC2AllEndpoints(snitch);
+ for (Entry<String, String> e : this.configOptions.entrySet())
+ {
+ if (!SchemaConstants.isSystemKeyspace(keyspaceName))
Review comment:
Right. Left-over from a refactor where ks was indeed changing then but it isn't now.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
[GitHub] [cassandra] tlasica commented on a change in pull request #870: CASSANDRA-16296 Warn on KS creation when RF > nodes
Posted by GitBox <gi...@apache.org>.
tlasica commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r571894188
##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
"max_threshold", "32")));
}
+ @Test
+ public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+ {
+ requireNetwork();
+ Thread.sleep(1000); // Hack: requireNetwork() will clear warnings async so give some time to complete
Review comment:
well, the difference is for a person debugging the failures:
"expected 0 warnings at the start of the test"
vs
"1 was expected and got 2" - after CREATE
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org