This is an automated email from the ASF dual-hosted git repository.

marcuse pushed a commit to branch cassandra-2.2
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-2.2 by this push:
     new 9081d00  Avoid adding fake row deletions if they are superseeded by 
the partition deletion
9081d00 is described below

commit 9081d0088119f02c8118598ac9fdb8ce39f0033b
Author: Marcus Eriksson <marc...@apache.org>
AuthorDate: Tue Oct 15 14:58:14 2019 +0200

    Avoid adding fake row deletions if they are superseeded by the partition 
deletion
    
    Patch by marcuse; reviewed by Aleksey Yeshchenko and Benedict Elliott Smith 
for CASSANDRA-15363
---
 .../cassandra/distributed/api/IInstance.java       |  3 ++
 .../impl/DelegatingInvokableInstance.java          | 10 ++++
 .../cassandra/distributed/impl/Instance.java       | 19 +++++++
 .../upgrade/MixedModeReadRepairTest.java           | 59 ++++++++++++++++++++++
 .../distributed/upgrade/UpgradeTestBase.java       | 16 +++++-
 5 files changed, 106 insertions(+), 1 deletion(-)

diff --git 
a/test/distributed/org/apache/cassandra/distributed/api/IInstance.java 
b/test/distributed/org/apache/cassandra/distributed/api/IInstance.java
index d5382b4..6a9e33a 100644
--- a/test/distributed/org/apache/cassandra/distributed/api/IInstance.java
+++ b/test/distributed/org/apache/cassandra/distributed/api/IInstance.java
@@ -47,4 +47,7 @@ public interface IInstance extends IIsolatedExecutor
 
     int getMessagingVersion();
     void setMessagingVersion(InetAddressAndPort endpoint, int version);
+
+    void flush(String keyspace);
+    void forceCompact(String keyspace, String table);
 }
diff --git 
a/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java
 
b/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java
index e9e6844..7294944 100644
--- 
a/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java
+++ 
b/test/distributed/org/apache/cassandra/distributed/impl/DelegatingInvokableInstance.java
@@ -85,6 +85,16 @@ public abstract class DelegatingInvokableInstance implements 
IInvokableInstance
         delegate().setMessagingVersion(endpoint, version);
     }
 
+    public void flush(String keyspace)
+    {
+        delegate().flush(keyspace);
+    }
+
+    public void forceCompact(String keyspace, String table)
+    {
+        delegate().forceCompact(keyspace, table);
+    }
+
     @Override
     public IInstanceConfig config()
     {
diff --git 
a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java 
b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
index af5ec65..e405d6b 100644
--- a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
+++ b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
@@ -343,6 +343,25 @@ public class Instance extends IsolatedExecutor implements 
IInvokableInstance
         runOnInstance(() -> 
MessagingService.instance().setVersion(endpoint.address, version));
     }
 
+    public void flush(String keyspace)
+    {
+        runOnInstance(() -> 
FBUtilities.waitOnFutures(Keyspace.open(keyspace).flush()));
+    }
+
+    public void forceCompact(String keyspace, String table)
+    {
+        runOnInstance(() -> {
+            try
+            {
+                
Keyspace.open(keyspace).getColumnFamilyStore(table).forceMajorCompaction();
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException(e);
+            }
+        });
+    }
+
     @Override
     public void startup(ICluster cluster)
     {
diff --git 
a/test/distributed/org/apache/cassandra/distributed/upgrade/MixedModeReadRepairTest.java
 
b/test/distributed/org/apache/cassandra/distributed/upgrade/MixedModeReadRepairTest.java
new file mode 100644
index 0000000..31f4b84
--- /dev/null
+++ 
b/test/distributed/org/apache/cassandra/distributed/upgrade/MixedModeReadRepairTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.upgrade;
+
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.distributed.impl.Versions;
+import org.apache.cassandra.distributed.test.DistributedTestBase;
+
+import static org.apache.cassandra.distributed.impl.Versions.find;
+
+public class MixedModeReadRepairTest extends UpgradeTestBase
+{
+    @Test
+    public void mixedModeReadRepairCompactStorage() throws Throwable
+    {
+        new TestCase()
+        .nodes(2)
+        .upgrade(Versions.Major.v22, Versions.Major.v30)
+        .nodesToUpgrade(2)
+        .setup((cluster) -> cluster.schemaChange("CREATE TABLE " + 
DistributedTestBase.KEYSPACE + ".tbl (pk ascii, b boolean, v blob, PRIMARY KEY 
(pk)) WITH COMPACT STORAGE"))
+        .runAfterClusterUpgrade((cluster) -> {
+            // now node2 is 3.0 and node1 is 2.2
+            // make sure 2.2 side does not get the mutation
+            cluster.get(2).executeInternal("DELETE FROM " + 
DistributedTestBase.KEYSPACE + ".tbl WHERE pk = ?",
+                                                                          
"something");
+            // trigger a read repair
+            cluster.coordinator(1).execute("SELECT * FROM " + 
DistributedTestBase.KEYSPACE + ".tbl WHERE pk = ?",
+                                           ConsistencyLevel.ALL,
+                                           "something");
+            cluster.get(1).flush(DistributedTestBase.KEYSPACE);
+            // upgrade node1 to 3.0
+            cluster.get(1).shutdown().get();
+            Versions allVersions = find();
+            
cluster.get(1).setVersion(allVersions.getLatest(Versions.Major.v30));
+            cluster.get(1).startup();
+
+            // and make sure the sstables are readable
+            cluster.get(1).forceCompact(DistributedTestBase.KEYSPACE, "tbl");
+        }).run();
+    }
+}
diff --git 
a/test/distributed/org/apache/cassandra/distributed/upgrade/UpgradeTestBase.java
 
b/test/distributed/org/apache/cassandra/distributed/upgrade/UpgradeTestBase.java
index 4403767..27094d8 100644
--- 
a/test/distributed/org/apache/cassandra/distributed/upgrade/UpgradeTestBase.java
+++ 
b/test/distributed/org/apache/cassandra/distributed/upgrade/UpgradeTestBase.java
@@ -20,7 +20,9 @@ package org.apache.cassandra.distributed.upgrade;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.cassandra.distributed.UpgradeableCluster;
 import org.apache.cassandra.distributed.impl.Instance;
@@ -63,6 +65,7 @@ public class UpgradeTestBase extends DistributedTestBase
         private RunOnCluster setup;
         private RunOnClusterAndNode runAfterNodeUpgrade;
         private RunOnCluster runAfterClusterUpgrade;
+        private final Set<Integer> nodesToUpgrade = new HashSet<>();
 
         public TestCase()
         {
@@ -125,6 +128,9 @@ public class UpgradeTestBase extends DistributedTestBase
                 runAfterClusterUpgrade = (c) -> {};
             if (runAfterNodeUpgrade == null)
                 runAfterNodeUpgrade = (c, n) -> {};
+            if (nodesToUpgrade.isEmpty())
+                for (int n = 1; n <= nodeCount; n++)
+                    nodesToUpgrade.add(n);
 
             for (TestVersions upgrade : this.upgrade)
             {
@@ -134,7 +140,7 @@ public class UpgradeTestBase extends DistributedTestBase
 
                     for (Version version : upgrade.upgrade)
                     {
-                        for (int n = 1 ; n <= nodeCount ; ++n)
+                        for (int n : nodesToUpgrade)
                         {
                             cluster.get(n).shutdown().get();
                             cluster.get(n).setVersion(version);
@@ -148,6 +154,14 @@ public class UpgradeTestBase extends DistributedTestBase
 
             }
         }
+        public TestCase nodesToUpgrade(int ... nodes)
+        {
+            for (int n : nodes)
+            {
+                nodesToUpgrade.add(n);
+            }
+            return this;
+        }
     }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to