jaydeepkumar1984 commented on code in PR #4365:
URL: https://github.com/apache/cassandra/pull/4365#discussion_r2389603898
##########
src/java/org/apache/cassandra/repair/consistent/LocalSessions.java:
##########
@@ -239,21 +240,46 @@ private boolean shouldStoreSession(LocalSession session)
*/
private boolean isSuperseded(LocalSession session)
{
+ // to reduce overheads of intersect calculation for tables within the
same keyspace
+ Map<String, Collection<Range<Token>>> rangesPerKeyspaceCache = new
HashMap<>();
for (TableId tid : session.tableIds)
{
- RepairedState state = repairedStates.get(tid);
+ TableMetadata tableMetadata = getTableMetadata(tid);
+ if (tableMetadata == null) // if a table was removed - ignore it
+ continue;
+ RepairedState state = repairedStates.get(tid);
if (state == null)
return false;
- long minRepaired = state.minRepairedAt(session.ranges);
+ Collection<Range<Token>> actualRanges =
rangesPerKeyspaceCache.computeIfAbsent(tableMetadata.keyspace, (keyspace) -> {
+ List<Range<Token>> localRanges =
getLocalRanges(tableMetadata.keyspace);
+ if (localRanges.isEmpty()) // to handle the case when we run
before the information about owned ranges is properly populated
+ return session.ranges;
+
+ // ignore token ranges which were moved to other nodes and not
onwed by the current one anymore
Review Comment:
nit: s/onwed/owned
##########
test/distributed/org/apache/cassandra/distributed/test/IncrementalRepairCleanupAfterNodeAddingTest.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.distributed.test;
+
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.ConsistencyLevel;
+import org.apache.cassandra.distributed.api.ICluster;
+import org.apache.cassandra.distributed.api.IInstanceConfig;
+import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.distributed.api.TokenSupplier;
+import org.apache.cassandra.distributed.shared.NetworkTopology;
+import org.apache.cassandra.distributed.shared.WithProperties;
+import org.apache.cassandra.service.ActiveRepairService;
+import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.utils.concurrent.SimpleCondition;
+import org.apache.cassandra.utils.progress.ProgressEventType;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
+import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+import static org.apache.cassandra.distributed.test.ExecUtil.rethrow;
+import static
org.apache.cassandra.repair.messages.RepairOption.INCREMENTAL_KEY;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+
+public class IncrementalRepairCleanupAfterNodeAddingTest extends TestBaseImpl
+{
+ @Test
+ public void test() throws Exception
+ {
+ int originalNodeCount = 3;
+ try (WithProperties withProperties = new WithProperties())
+ {
+
withProperties.setProperty("cassandra.repair_delete_timeout_seconds", "0");
+ try (Cluster cluster = builder().withNodes(originalNodeCount)
+
.withTokenSupplier(TokenSupplier.evenlyDistributedTokens(originalNodeCount + 1,
1))
+
.withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(4, "dc0", "rack0"))
+ .withConfig(config ->
config.with(NETWORK, GOSSIP, NATIVE_PROTOCOL))
+ .start())
+ {
+ populate(cluster, 0, 100);
+
+ repair(cluster, KEYSPACE, ImmutableMap.of(INCREMENTAL_KEY,
"true"));
+
Review Comment:
We should do a check here after sleeping to ensure that the session count is
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]