You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "smiklosovic (via GitHub)" <gi...@apache.org> on 2023/04/20 09:10:38 UTC

[GitHub] [cassandra] smiklosovic opened a new pull request, #2286: CASSANDRA-18105 3.0

smiklosovic opened a new pull request, #2286:
URL: https://github.com/apache/cassandra/pull/2286

   Thanks for sending a pull request! Here are some tips if you're new here:
    
    * Ensure you have added or run the [appropriate tests](https://cassandra.apache.org/_/development/testing.html) for your PR.
    * Be sure to keep the PR description updated to reflect all changes.
    * Write your PR title to summarize what this PR proposes.
    * If possible, provide a concise example to reproduce the issue for a faster review.
    * Read our [contributor guidelines](https://cassandra.apache.org/_/development/index.html)
    * If you're making a documentation change, see our [guide to documentation contribution](https://cassandra.apache.org/_/development/documentation.html)
    
   Commit messages should follow the following format:
   
   ```
   <One sentence description, usually Jira title or CHANGES.txt summary>
   
   <Optional lengthier description (context on patch)>
   
   patch by <Authors>; reviewed by <Reviewers> for CASSANDRA-#####
   
   Co-authored-by: Name1 <email1>
   Co-authored-by: Name2 <email2>
   
   ```
   
   The [Cassandra Jira](https://issues.apache.org/jira/projects/CASSANDRA/issues/)
   
   


-- 
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


[GitHub] [cassandra] Maxwell-Guo commented on a diff in pull request #2286: CASSANDRA-18105 3.0

Posted by "Maxwell-Guo (via GitHub)" <gi...@apache.org>.
Maxwell-Guo commented on code in PR #2286:
URL: https://github.com/apache/cassandra/pull/2286#discussion_r1172320918


##########
test/distributed/org/apache/cassandra/distributed/test/IndexAndMVDroppingTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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 org.junit.Test;
+
+import org.apache.cassandra.distributed.Cluster;
+
+import static org.apache.cassandra.distributed.Cluster.build;
+import static org.apache.cassandra.distributed.api.ConsistencyLevel.ONE;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests CASSANDRA-18105.
+ * <p>
+ * Trucation will insert an entry to system.local into truncated_at map for given table. Because id of an index

Review Comment:
   Trucation -> Truncation ?  Am I right?



-- 
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


[GitHub] [cassandra] maedhroz commented on a diff in pull request #2286: CASSANDRA-18105 3.0

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2286:
URL: https://github.com/apache/cassandra/pull/2286#discussion_r1174062984


##########
test/distributed/org/apache/cassandra/distributed/test/IndexAndMVDroppingTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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 org.junit.Test;
+
+import org.apache.cassandra.distributed.Cluster;
+
+import static org.apache.cassandra.distributed.Cluster.build;
+import static org.apache.cassandra.distributed.api.ConsistencyLevel.ONE;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests CASSANDRA-18105.
+ * <p>
+ * Trucation will insert an entry to system.local into truncated_at map for given table. Because id of an index
+ * is same as id of the base table, when dropping an index, it in fact drops a table with same id as the base table
+ * which will remove an entry for trucated_at column. Hence, after restart of the node, querying the base table
+ * will resurrect the data because commitlog was fully replayed, not taking into consideration (now removed) entry
+ * in truncated_at column.
+ * <p>
+ * The fix consists of not removing an entry in trucated_at column in system.local
+ * if the table being removed is an index.
+ */
+public class IndexAndMVDroppingTest extends TestBaseImpl
+{

Review Comment:
   nit: We could cut down running time a little if we share the cluster. Something like...
   
   ```
   private static Cluster CLUSTER;
   
   @BeforeClass
   public static void init() throws IOException
   {
       CLUSTER = init(Cluster.create(1, conf -> conf.with(NETWORK)));
   }
   
   @AfterClass
   public static void shutdown()
   {
       if (CLUSTER != null)
           CLUSTER.close();
   }
   
   @After
   public void reset()
   {
       if (CLUSTER.get(1).isShutdown())
           CLUSTER.get(1).startup(); // make sure we get the cluster running for test that follow a poorly timed failure
   }
   ```



-- 
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


[GitHub] [cassandra] smiklosovic closed pull request #2286: CASSANDRA-18105 3.0

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic closed pull request #2286: CASSANDRA-18105 3.0
URL: https://github.com/apache/cassandra/pull/2286


-- 
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


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2286: CASSANDRA-18105 3.0

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2286:
URL: https://github.com/apache/cassandra/pull/2286#discussion_r1172308436


##########
test/distributed/org/apache/cassandra/distributed/test/IndexAndMVDroppingTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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 org.junit.Test;
+
+import org.apache.cassandra.distributed.Cluster;
+
+import static org.apache.cassandra.distributed.Cluster.build;
+import static org.apache.cassandra.distributed.api.ConsistencyLevel.ONE;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests CASSANDRA-18105.
+ * <p>
+ * Trucation will insert an entry to system.local into truncated_at map for given table. Because id of an index
+ * is same as id of the base table, when dropping an index, it in fact drops a table with same id as the base table
+ * which will remove an entry for trucated_at column. Hence, after restart of the node, querying the base table
+ * will resurrect the data because commitlog was fully replayed, not taking into consideration (now removed) entry
+ * in truncated_at column.
+ * <p>
+ * The fix consists of not removing an entry in trucated_at column in system.local
+ * if the table being removed is an index.
+ */
+public class IndexAndMVDroppingTest extends TestBaseImpl
+{
+    @Test
+    public void testIndexDropping() throws Throwable
+    {
+        try (Cluster c = build(1).withConfig(conf -> conf.with(NETWORK)).start())
+        {
+            c.schemaChange("CREATE KEYSPACE " + KEYSPACE + " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }");
+            c.schemaChange("CREATE TABLE " + KEYSPACE + ".tb (c3 TEXT, c4 TEXT, c2 INT, c1 TEXT, PRIMARY KEY (c1, c2, c3 ))");
+            c.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tb (c3, c1, c2) VALUES ('val1','val2',1)", ONE);
+            c.schemaChange("CREATE INDEX tb ON " + KEYSPACE + ".tb (c3)");
+            c.schemaChange("TRUNCATE TABLE " + KEYSPACE + " .tb");
+            c.schemaChange("DROP INDEX " + KEYSPACE + ".tb");
+
+            assertEquals(0, c.coordinator(1).execute("SELECT c2 FROM " + KEYSPACE + " .tb", ONE).length);
+
+            c.get(1).shutdown(true).get();
+            c.get(1).startup();
+
+            assertEquals(0, c.coordinator(1).execute("SELECT c2 FROM " + KEYSPACE + " .tb", ONE).length);
+        }
+    }
+
+    @Test
+    public void testMaterializedViewDropping() throws Throwable

Review Comment:
   I added MV case as well, just to be sure.



-- 
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


[GitHub] [cassandra] maedhroz commented on a diff in pull request #2286: CASSANDRA-18105 3.0

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2286:
URL: https://github.com/apache/cassandra/pull/2286#discussion_r1174053832


##########
src/java/org/apache/cassandra/db/ColumnFamilyStore.java:
##########
@@ -538,7 +538,9 @@ public void invalidate(boolean expectMBean)
 
         latencyCalculator.cancel(false);
         compactionStrategyManager.shutdown();
-        SystemKeyspace.removeTruncationRecord(metadata.cfId);
+
+        if (!metadata.isIndex())

Review Comment:
   nit: Might be a good idea to throw a comment inline, something like...
   
   > // Do not remove truncation records for index CFs, given they have the same ID as their backing/base tables.



-- 
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