You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "arkn98 (via GitHub)" <gi...@apache.org> on 2024/06/06 04:07:57 UTC
[PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
arkn98 opened a new pull request, #3350:
URL: https://github.com/apache/cassandra/pull/3350
Patch by Arun Ganesh; reviewed by TBD for CASSANDRA-19400
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1679772941
##########
test/unit/org/apache/cassandra/index/IndexStatusManagerTest.java:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.index;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.gms.VersionedValue;
+import org.apache.cassandra.locator.*;
+import org.apache.cassandra.utils.JsonUtils;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.schema.IndexMetadata;
+import org.mockito.Mockito;
+
+import static org.apache.cassandra.locator.ReplicaUtils.full;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertArrayEquals;
+
+public class IndexStatusManagerTest
+{
+ static class Testcase
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Testcase(Builder builder)
+ {
+ keyspace = builder.keyspace;
+ minRequiredNodes = builder.minRequiredNodes;
+ replicationStrategy = builder.replicationStrategy;
+ indexStatus = builder.indexStatus;
+ expected = builder.expected;
+ }
+
+ static class Builder
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Builder keyspace(String kp)
+ {
+ keyspace = kp;
+ return this;
+ }
+
+ Builder minRequiredNodes(int required)
+ {
+ minRequiredNodes = required;
+ return this;
+ }
+
+ Builder replicationStrategy(AbstractReplicationStrategy strategy)
+ {
+ replicationStrategy = strategy;
+ return this;
+ }
+
+ Builder indexStatus(Map<InetAddressAndPort, Map<String, Index.Status>> status)
+ {
+ indexStatus = status;
+ return this;
+ }
+
+ Builder expected(EndpointsForRange endpoints)
+ {
+ expected = endpoints;
+ return this;
+ }
+
+ Testcase build()
+ {
+ return new Testcase(this);
+ }
+ }
+ }
+
+ // we have enough BUILD_SUCCEEDED endpoints: filterForQuery should prioritize them, even if the other endpoints'
+ // indexes are queryable but not built (like UNKNOWN)
+ @Test
+ public void filterForQuery_ShouldPrioritizeSuccessfulEndpoints()
+ {
+ runTest("exactly enough endpoints with BUILD_SUCCEEDED indexes",
Review Comment:
I'd make this its own top-level test, called perhaps `shouldPrioritizeSingleSuccessfulEndpoint()`
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1679773329
##########
test/unit/org/apache/cassandra/index/IndexStatusManagerTest.java:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.index;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.gms.VersionedValue;
+import org.apache.cassandra.locator.*;
+import org.apache.cassandra.utils.JsonUtils;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.schema.IndexMetadata;
+import org.mockito.Mockito;
+
+import static org.apache.cassandra.locator.ReplicaUtils.full;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertArrayEquals;
+
+public class IndexStatusManagerTest
+{
+ static class Testcase
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Testcase(Builder builder)
+ {
+ keyspace = builder.keyspace;
+ minRequiredNodes = builder.minRequiredNodes;
+ replicationStrategy = builder.replicationStrategy;
+ indexStatus = builder.indexStatus;
+ expected = builder.expected;
+ }
+
+ static class Builder
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Builder keyspace(String kp)
+ {
+ keyspace = kp;
+ return this;
+ }
+
+ Builder minRequiredNodes(int required)
+ {
+ minRequiredNodes = required;
+ return this;
+ }
+
+ Builder replicationStrategy(AbstractReplicationStrategy strategy)
+ {
+ replicationStrategy = strategy;
+ return this;
+ }
+
+ Builder indexStatus(Map<InetAddressAndPort, Map<String, Index.Status>> status)
+ {
+ indexStatus = status;
+ return this;
+ }
+
+ Builder expected(EndpointsForRange endpoints)
+ {
+ expected = endpoints;
+ return this;
+ }
+
+ Testcase build()
+ {
+ return new Testcase(this);
+ }
+ }
+ }
+
+ // we have enough BUILD_SUCCEEDED endpoints: filterForQuery should prioritize them, even if the other endpoints'
+ // indexes are queryable but not built (like UNKNOWN)
+ @Test
+ public void filterForQuery_ShouldPrioritizeSuccessfulEndpoints()
+ {
+ runTest("exactly enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.UNKNOWN,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(1)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254"))
+ ))
+ .build()
+ );
+
+ runTest("more than enough endpoints with BUILD_SUCCEEDED indexes",
Review Comment:
I'd make this its own top-level test, called perhaps `shouldPrioritizeMultipleSuccessfulEndpoints()`
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "arkn98 (via GitHub)" <gi...@apache.org>.
arkn98 commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1689059077
##########
src/java/org/apache/cassandra/index/IndexStatusManager.java:
##########
@@ -84,26 +85,39 @@ private IndexStatusManager()
*/
public <E extends Endpoints<E>> E filterForQuery(E liveEndpoints, Keyspace keyspace, Index.QueryPlan indexQueryPlan, ConsistencyLevel level)
Review Comment:
Addressed in the latest commit. Thanks for the review!
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#issuecomment-2248866091
Committed as https://github.com/apache/cassandra/commit/b8d69d02614973d79d2c70d65aea4612dad6e36c
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz closed pull request #3350: CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones
URL: https://github.com/apache/cassandra/pull/3350
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1679776798
##########
test/unit/org/apache/cassandra/index/IndexStatusManagerTest.java:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.index;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.gms.VersionedValue;
+import org.apache.cassandra.locator.*;
+import org.apache.cassandra.utils.JsonUtils;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.schema.IndexMetadata;
+import org.mockito.Mockito;
+
+import static org.apache.cassandra.locator.ReplicaUtils.full;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertArrayEquals;
+
+public class IndexStatusManagerTest
+{
+ static class Testcase
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Testcase(Builder builder)
+ {
+ keyspace = builder.keyspace;
+ minRequiredNodes = builder.minRequiredNodes;
+ replicationStrategy = builder.replicationStrategy;
+ indexStatus = builder.indexStatus;
+ expected = builder.expected;
+ }
+
+ static class Builder
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Builder keyspace(String kp)
+ {
+ keyspace = kp;
+ return this;
+ }
+
+ Builder minRequiredNodes(int required)
+ {
+ minRequiredNodes = required;
+ return this;
+ }
+
+ Builder replicationStrategy(AbstractReplicationStrategy strategy)
+ {
+ replicationStrategy = strategy;
+ return this;
+ }
+
+ Builder indexStatus(Map<InetAddressAndPort, Map<String, Index.Status>> status)
+ {
+ indexStatus = status;
+ return this;
+ }
+
+ Builder expected(EndpointsForRange endpoints)
+ {
+ expected = endpoints;
+ return this;
+ }
+
+ Testcase build()
+ {
+ return new Testcase(this);
+ }
+ }
+ }
+
+ // we have enough BUILD_SUCCEEDED endpoints: filterForQuery should prioritize them, even if the other endpoints'
+ // indexes are queryable but not built (like UNKNOWN)
+ @Test
+ public void filterForQuery_ShouldPrioritizeSuccessfulEndpoints()
+ {
+ runTest("exactly enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.UNKNOWN,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(1)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254"))
+ ))
+ .build()
+ );
+
+ runTest("more than enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.UNKNOWN,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.252"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.251"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(2)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.252")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.251"))
+ ))
+ .build()
+ );
+ }
+
+ // we don't have enough BUILD_SUCCEEDED endpoints: filterForQuery should return all queryable endpoints
+ @Test
+ public void filterForQuery_ReturnAllEndpointsWhenNotEnoughSuccessfulEndpoints()
+ {
+ runTest("not enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.UNKNOWN,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.252"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_FAILED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.251"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.UNKNOWN,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(3)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.255")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.253")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.251"))
+ ))
+ .build()
+ );
+ }
+
+ // we don't have enough queryable endpoints: filterForQuery should throw an exception
+ @Test
+ public void filterForQuery_ThrowExceptionWhenNotEnoughQueryableEndpoints()
+ {
+ assertThatThrownBy(() ->
+ runTest("not enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.UNKNOWN,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_FAILED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.252"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_FAILED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.251"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.UNKNOWN,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(4)
+ .build()))
+ .isInstanceOf(ReadFailureException.class)
+ .hasMessageStartingWith("Operation failed")
+ .hasMessageContaining("INDEX_NOT_AVAILABLE from /127.0.0.254:7000")
+ .hasMessageContaining("INDEX_NOT_AVAILABLE from /127.0.0.252:7000");
+
+ assertThatThrownBy(() ->
Review Comment:
I'd make this its own top-level test, called perhaps `shouldThrowWithNoQueryableEndpoints()`
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1679774423
##########
test/unit/org/apache/cassandra/index/IndexStatusManagerTest.java:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.index;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.gms.VersionedValue;
+import org.apache.cassandra.locator.*;
+import org.apache.cassandra.utils.JsonUtils;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.schema.IndexMetadata;
+import org.mockito.Mockito;
+
+import static org.apache.cassandra.locator.ReplicaUtils.full;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertArrayEquals;
+
+public class IndexStatusManagerTest
+{
+ static class Testcase
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Testcase(Builder builder)
+ {
+ keyspace = builder.keyspace;
+ minRequiredNodes = builder.minRequiredNodes;
+ replicationStrategy = builder.replicationStrategy;
+ indexStatus = builder.indexStatus;
+ expected = builder.expected;
+ }
+
+ static class Builder
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Builder keyspace(String kp)
+ {
+ keyspace = kp;
+ return this;
+ }
+
+ Builder minRequiredNodes(int required)
+ {
+ minRequiredNodes = required;
+ return this;
+ }
+
+ Builder replicationStrategy(AbstractReplicationStrategy strategy)
+ {
+ replicationStrategy = strategy;
+ return this;
+ }
+
+ Builder indexStatus(Map<InetAddressAndPort, Map<String, Index.Status>> status)
+ {
+ indexStatus = status;
+ return this;
+ }
+
+ Builder expected(EndpointsForRange endpoints)
+ {
+ expected = endpoints;
+ return this;
+ }
+
+ Testcase build()
+ {
+ return new Testcase(this);
+ }
+ }
+ }
+
+ // we have enough BUILD_SUCCEEDED endpoints: filterForQuery should prioritize them, even if the other endpoints'
+ // indexes are queryable but not built (like UNKNOWN)
+ @Test
+ public void filterForQuery_ShouldPrioritizeSuccessfulEndpoints()
+ {
+ runTest("exactly enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.UNKNOWN,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(1)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254"))
+ ))
+ .build()
+ );
+
+ runTest("more than enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.UNKNOWN,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.252"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.251"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(2)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.252")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.251"))
+ ))
+ .build()
+ );
+ }
+
+ // we don't have enough BUILD_SUCCEEDED endpoints: filterForQuery should return all queryable endpoints
+ @Test
+ public void filterForQuery_ReturnAllEndpointsWhenNotEnoughSuccessfulEndpoints()
Review Comment:
```suggestion
public void shouldIncludeUnknownEndpointsWhenNotEnoughSucceeded()
```
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "arkn98 (via GitHub)" <gi...@apache.org>.
arkn98 commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1631802998
##########
src/java/org/apache/cassandra/index/IndexStatusManager.java:
##########
@@ -84,26 +85,39 @@ private IndexStatusManager()
*/
public <E extends Endpoints<E>> E filterForQuery(E liveEndpoints, Keyspace keyspace, Index.QueryPlan indexQueryPlan, ConsistencyLevel level)
{
+ int required = level.blockFor(keyspace.getReplicationStrategy());
+ ReplicaCollection.Builder<E> buildSucceededEndpoints = liveEndpoints.newBuilder(0);
Review Comment:
I'm no expert, but what you suggested makes sense. I'll use `liveEndpoints.size()`.
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1629961763
##########
src/java/org/apache/cassandra/index/IndexStatusManager.java:
##########
@@ -84,26 +85,39 @@ private IndexStatusManager()
*/
public <E extends Endpoints<E>> E filterForQuery(E liveEndpoints, Keyspace keyspace, Index.QueryPlan indexQueryPlan, ConsistencyLevel level)
{
+ int required = level.blockFor(keyspace.getReplicationStrategy());
+ ReplicaCollection.Builder<E> buildSucceededEndpoints = liveEndpoints.newBuilder(0);
Review Comment:
```suggestion
ReplicaCollection.Builder<E> buildSucceededEndpoints = liveEndpoints.newBuilder(liveEndpoints.size());
```
The only other option would be to use `required` as an initial size, but I think we'll expect most nodes to be in the `BUILD_SUCCEEDED` state most of the time, so that would force more array creations. For instance, if we have an RF = 3, and CL = QUORUM, we probably want to use `liveEndpoints.size()` which would be 3, instead of using 2 and having to do an extra array copy if all three replicas are `BUILD_SUCCEEDED`.
WDYT?
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "jasonstack (via GitHub)" <gi...@apache.org>.
jasonstack commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1685207373
##########
src/java/org/apache/cassandra/index/IndexStatusManager.java:
##########
@@ -84,26 +85,39 @@ private IndexStatusManager()
*/
public <E extends Endpoints<E>> E filterForQuery(E liveEndpoints, Keyspace keyspace, Index.QueryPlan indexQueryPlan, ConsistencyLevel level)
Review Comment:
The next call after `filterForQuery` is to filter for EACH_QUOUM in `ReplicaPlans#contactForRead`. If 1st DC has 3 succeeded replicas and 2nd DC has 3 unknown repliacs. `filterForQuery` will return 3 succeeded + 1 unknown and will fail the consistency requirement for `EACH_QUOUM`. Not sure if we care about EACH_QUOUM for indexes.
The safest approach here is to sort replicas by query status. How about following?
```
Set<Replica> queryableNonSucceeded = new HashSet<>(liveEndpoints.size());
E queryableEndpoints = liveEndpoints.filter(replica -> {
boolean allBuilt = true;
for (Index index : indexQueryPlan.getIndexes())
{
Index.Status status = getIndexStatus(replica.endpoint(), keyspace.getName(), index.getIndexMetadata().name);
if (!index.isQueryable(status))
return false;
if (status != Index.Status.BUILD_SUCCEEDED)
allBuilt = false;
}
if (!allBuilt)
queryableNonSucceeded.add(replica);
return true;
});
// deprioritize replica with queryable but non-succeeded state
if (!queryableNonSucceeded.isEmpty())
queryableEndpoints = queryableEndpoints.sorted(Comparator.comparingInt(r -> queryableNonSucceeded.contains(r) ? 1 : -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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1679776115
##########
test/unit/org/apache/cassandra/index/IndexStatusManagerTest.java:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.index;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.gms.VersionedValue;
+import org.apache.cassandra.locator.*;
+import org.apache.cassandra.utils.JsonUtils;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.schema.IndexMetadata;
+import org.mockito.Mockito;
+
+import static org.apache.cassandra.locator.ReplicaUtils.full;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertArrayEquals;
+
+public class IndexStatusManagerTest
+{
+ static class Testcase
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Testcase(Builder builder)
+ {
+ keyspace = builder.keyspace;
+ minRequiredNodes = builder.minRequiredNodes;
+ replicationStrategy = builder.replicationStrategy;
+ indexStatus = builder.indexStatus;
+ expected = builder.expected;
+ }
+
+ static class Builder
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Builder keyspace(String kp)
+ {
+ keyspace = kp;
+ return this;
+ }
+
+ Builder minRequiredNodes(int required)
+ {
+ minRequiredNodes = required;
+ return this;
+ }
+
+ Builder replicationStrategy(AbstractReplicationStrategy strategy)
+ {
+ replicationStrategy = strategy;
+ return this;
+ }
+
+ Builder indexStatus(Map<InetAddressAndPort, Map<String, Index.Status>> status)
+ {
+ indexStatus = status;
+ return this;
+ }
+
+ Builder expected(EndpointsForRange endpoints)
+ {
+ expected = endpoints;
+ return this;
+ }
+
+ Testcase build()
+ {
+ return new Testcase(this);
+ }
+ }
+ }
+
+ // we have enough BUILD_SUCCEEDED endpoints: filterForQuery should prioritize them, even if the other endpoints'
+ // indexes are queryable but not built (like UNKNOWN)
+ @Test
+ public void filterForQuery_ShouldPrioritizeSuccessfulEndpoints()
+ {
+ runTest("exactly enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.UNKNOWN,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(1)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254"))
+ ))
+ .build()
+ );
+
+ runTest("more than enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.UNKNOWN,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.252"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.251"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(2)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.252")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.251"))
+ ))
+ .build()
+ );
+ }
+
+ // we don't have enough BUILD_SUCCEEDED endpoints: filterForQuery should return all queryable endpoints
+ @Test
+ public void filterForQuery_ReturnAllEndpointsWhenNotEnoughSuccessfulEndpoints()
+ {
+ runTest("not enough endpoints with BUILD_SUCCEEDED indexes",
+ new Testcase.Builder()
+ .keyspace("ks1")
+ .replicationStrategy(new NetworkTopologyStrategy("ks1", Map.of("DC", "5")))
+ .indexStatus(Map.of(
+ InetAddressAndPort.getByNameUnchecked("127.0.0.255"),
+ Map.of(
+ "ks1.idx1", Index.Status.UNKNOWN,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.254"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.UNKNOWN
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.253"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.252"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.BUILD_FAILED,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ ),
+ InetAddressAndPort.getByNameUnchecked("127.0.0.251"),
+ Map.of(
+ "ks1.idx1", Index.Status.BUILD_SUCCEEDED,
+ "ks1.idx2", Index.Status.UNKNOWN,
+ "ks1.idx3", Index.Status.BUILD_SUCCEEDED
+ )
+ ))
+ .minRequiredNodes(3)
+ .expected(EndpointsForRange.of(
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.255")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.254")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.253")),
+ full(InetAddressAndPort.getByNameUnchecked("127.0.0.251"))
+ ))
+ .build()
+ );
+ }
+
+ // we don't have enough queryable endpoints: filterForQuery should throw an exception
+ @Test
+ public void filterForQuery_ThrowExceptionWhenNotEnoughQueryableEndpoints()
+ {
+ assertThatThrownBy(() ->
Review Comment:
I'd make this its own top-level test, called perhaps `shouldThrowWhenNotEnoughQueryableEndpoints()`
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1679770315
##########
test/unit/org/apache/cassandra/index/IndexStatusManagerTest.java:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.index;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ReadFailureException;
+import org.apache.cassandra.gms.VersionedValue;
+import org.apache.cassandra.locator.*;
+import org.apache.cassandra.utils.JsonUtils;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.schema.IndexMetadata;
+import org.mockito.Mockito;
+
+import static org.apache.cassandra.locator.ReplicaUtils.full;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertArrayEquals;
+
+public class IndexStatusManagerTest
+{
+ static class Testcase
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Testcase(Builder builder)
+ {
+ keyspace = builder.keyspace;
+ minRequiredNodes = builder.minRequiredNodes;
+ replicationStrategy = builder.replicationStrategy;
+ indexStatus = builder.indexStatus;
+ expected = builder.expected;
+ }
+
+ static class Builder
+ {
+ String keyspace;
+ int minRequiredNodes;
+ AbstractReplicationStrategy replicationStrategy;
+ Map<InetAddressAndPort, Map<String, Index.Status>> indexStatus;
+ EndpointsForRange expected;
+
+ Builder keyspace(String kp)
Review Comment:
```suggestion
Builder keyspace(String ks)
```
super nit: We usually use "ks" as an abbreviation for keyspace, but no important
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1685233274
##########
src/java/org/apache/cassandra/index/IndexStatusManager.java:
##########
@@ -84,26 +85,39 @@ private IndexStatusManager()
*/
public <E extends Endpoints<E>> E filterForQuery(E liveEndpoints, Keyspace keyspace, Index.QueryPlan indexQueryPlan, ConsistencyLevel level)
Review Comment:
`contactForRead()` just generates a sub-list from left to right, so that should work. In most cases, the sort shouldn't even happen, as `UNKNOWN` states should be transient/rare. Since the number of nodes in this state should very small, and we may have a large cluster, I'd also make the initial size of `queryableNonSucceeded` something reasonably small, like 4 (w/ a comment), or even use the default (16). With the `ReplicaCollection.Builder` it made sense to do the opposite, but that, in retrospect, would not have been very nice either in a large cluster with most things built/succeeded (aside from avoiding resizing).
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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
Re: [PR] CASSANDRA-19400 IndexStatusManager should prioritize replicas with BUILD_SUCCEEDED indexes over UNKNOWN ones [cassandra]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1685233753
##########
src/java/org/apache/cassandra/index/IndexStatusManager.java:
##########
@@ -84,26 +85,39 @@ private IndexStatusManager()
*/
public <E extends Endpoints<E>> E filterForQuery(E liveEndpoints, Keyspace keyspace, Index.QueryPlan indexQueryPlan, ConsistencyLevel level)
Review Comment:
For partition-restricted index queries, the `liveEndpoints` might be small, of course, but I'd still size `queryableNonSucceeded` explicitly at something like 4.
--
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.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
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