You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bl...@apache.org on 2015/09/09 22:23:32 UTC

[1/5] cassandra git commit: Cleanup, scrub and upgrade may unmark compacting early (CASSANDRA-10274)

Repository: cassandra
Updated Branches:
  refs/heads/trunk c5408a3a1 -> e5acb5604


Cleanup, scrub and upgrade may unmark compacting early (CASSANDRA-10274)

If an error occured during cleanup, scrub or upgrade
(or any parallelAllSSTableOperation), the caller was immediately
notified of the problem, and the method exited, executing the
finally block that unmarked all of the sstables as compacting.

Since the operations happen in parallel, many may still be running
or waiting to run, and so another operation may operate over the
same sstables, breaking the required mutual exclusivity.

This patch ensures the method is not exited until all operations
have completed, at which point the caller is notified of any
exceptions.

patch by benedict; reviewed by marcus for CASSANDRA-10274


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/04e789bb
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/04e789bb
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/04e789bb

Branch: refs/heads/trunk
Commit: 04e789bbcf283fe1d3b16613321ee169fa9f4e27
Parents: c2eb7bd
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Mon Sep 7 12:23:57 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Tue Sep 8 13:24:18 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                      |  2 ++
 .../db/compaction/CompactionManager.java         |  3 +--
 .../org/apache/cassandra/utils/FBUtilities.java  | 19 ++++++++++++++++---
 .../org/apache/cassandra/utils/Throwables.java   |  5 +++++
 4 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/04e789bb/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6d43c98..e3ad5e8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.1.10
+ * Scrub, Cleanup and Upgrade do not unmark compacting until all operations
+   have completed, regardless of the occurence of exceptions (CASSANDRA-10274)
  * Fix handling of streaming EOF (CASSANDRA-10206)
  * Only check KeyCache when it is enabled
  * Change streaming_socket_timeout_in_ms default to 1 hour (CASSANDRA-8611)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/04e789bb/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 3cfbe43..5d88a11 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -280,8 +280,7 @@ public class CompactionManager implements CompactionManagerMBean
                 }));
             }
 
-            for (Future<Object> f : futures)
-                f.get();
+            FBUtilities.waitOnFutures(futures);
         }
         finally
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/04e789bb/src/java/org/apache/cassandra/utils/FBUtilities.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/FBUtilities.java b/src/java/org/apache/cassandra/utils/FBUtilities.java
index 1b118ba..214f2f5 100644
--- a/src/java/org/apache/cassandra/utils/FBUtilities.java
+++ b/src/java/org/apache/cassandra/utils/FBUtilities.java
@@ -344,10 +344,23 @@ public class FBUtilities
         return System.currentTimeMillis() * 1000;
     }
 
-    public static void waitOnFutures(Iterable<Future<?>> futures)
+    public static <T> List<T> waitOnFutures(Iterable<? extends Future<? extends T>> futures)
     {
-        for (Future f : futures)
-            waitOnFuture(f);
+        List<T> results = new ArrayList<>();
+        Throwable fail = null;
+        for (Future<? extends T> f : futures)
+        {
+            try
+            {
+                results.add(f.get());
+            }
+            catch (InterruptedException | ExecutionException e)
+            {
+                fail = Throwables.merge(fail, e);
+            }
+        }
+        Throwables.maybeFail(fail);
+        return results;
     }
 
     public static <T> T waitOnFuture(Future<T> future)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/04e789bb/src/java/org/apache/cassandra/utils/Throwables.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/Throwables.java b/src/java/org/apache/cassandra/utils/Throwables.java
index 552ca87..0a2bd28 100644
--- a/src/java/org/apache/cassandra/utils/Throwables.java
+++ b/src/java/org/apache/cassandra/utils/Throwables.java
@@ -29,4 +29,9 @@ public class Throwables
         return existingFail;
     }
 
+    public static void maybeFail(Throwable fail)
+    {
+        if (fail != null)
+            com.google.common.base.Throwables.propagate(fail);
+    }
 }


[5/5] cassandra git commit: Merge branch cassandra-3.0 into trunk

Posted by bl...@apache.org.
Merge branch cassandra-3.0 into trunk


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e5acb560
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e5acb560
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e5acb560

Branch: refs/heads/trunk
Commit: e5acb56043984efcc677f395087ed9b012f28ee0
Parents: c5408a3 cc0038b
Author: blerer <be...@datastax.com>
Authored: Wed Sep 9 22:22:33 2015 +0200
Committer: blerer <be...@datastax.com>
Committed: Wed Sep 9 22:22:55 2015 +0200

----------------------------------------------------------------------
 .../validation/entities/CollectionsTest.java     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------



[4/5] cassandra git commit: Merge branch cassandra-2.2 into cassandra-3.0

Posted by bl...@apache.org.
Merge branch cassandra-2.2 into cassandra-3.0


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/cc0038b7
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/cc0038b7
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/cc0038b7

Branch: refs/heads/trunk
Commit: cc0038b7d196d8cd072931bbf28ad276f7987abf
Parents: e097efc ec4b4d4
Author: blerer <be...@datastax.com>
Authored: Wed Sep 9 22:13:48 2015 +0200
Committer: blerer <be...@datastax.com>
Committed: Wed Sep 9 22:20:58 2015 +0200

----------------------------------------------------------------------
 .../validation/entities/CollectionsTest.java     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cc0038b7/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
index 088b9cf,6266fe7..df8d507
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
@@@ -590,81 -585,26 +590,100 @@@ public class CollectionsTest extends CQ
          assertInvalid("alter table %s add v set<int>");
      }
  
 -    /**
 -     * Test for 9838.
 -     */
 +    @Test
 +    public void testDropAndReaddDroppedCollection() throws Throwable
 +    {
 +        createTable("create table %s (k int primary key, v frozen<set<text>>, x int)");
 +        execute("insert into %s (k, v) VALUES (0, {'fffffffff'})");
 +        flush();
 +        execute("alter table %s drop v");
 +        execute("alter table %s add v set<int>");
 +    }
 +
 +    @Test
 +    public void testMapWithLargePartition() throws Throwable
 +    {
 +        Random r = new Random();
 +        long seed = System.nanoTime();
 +        System.out.println("Seed " + seed);
 +        r.setSeed(seed);
 +
 +        int len = (1024 * 1024)/100;
 +        createTable("CREATE TABLE %s (userid text PRIMARY KEY, properties map<int, text>) with compression = {}");
 +
 +        final int numKeys = 200;
 +        for (int i = 0; i < numKeys; i++)
 +        {
 +            byte[] b = new byte[len];
 +            r.nextBytes(b);
 +            execute("UPDATE %s SET properties[?] = ? WHERE userid = 'user'", i, new String(b));
 +        }
 +
 +        flush();
 +
 +        Object[][] rows = getRows(execute("SELECT properties from %s where userid = 'user'"));
 +        assertEquals(1, rows.length);
 +        assertEquals(numKeys, ((Map) rows[0][0]).size());
 +    }
 +
 +    @Test
 +    public void testMapWithTwoSStables() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (userid text PRIMARY KEY, properties map<int, text>) with compression = {}");
 +
 +        final int numKeys = 100;
 +        for (int i = 0; i < numKeys; i++)
 +            execute("UPDATE %s SET properties[?] = ? WHERE userid = 'user'", i, "prop_" + Integer.toString(i));
 +
 +        flush();
 +
 +        for (int i = numKeys; i < 2*numKeys; i++)
 +            execute("UPDATE %s SET properties[?] = ? WHERE userid = 'user'", i, "prop_" + Integer.toString(i));
 +
 +        flush();
 +
 +        Object[][] rows = getRows(execute("SELECT properties from %s where userid = 'user'"));
 +        assertEquals(1, rows.length);
 +        assertEquals(numKeys * 2, ((Map) rows[0][0]).size());
 +    }
 +
 +    @Test
 +    public void testSetWithTwoSStables() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (userid text PRIMARY KEY, properties set<text>) with compression = {}");
 +
 +        final int numKeys = 100;
 +        for (int i = 0; i < numKeys; i++)
 +            execute("UPDATE %s SET properties = properties + ? WHERE userid = 'user'", set("prop_" + Integer.toString(i)));
 +
 +        flush();
 +
 +        for (int i = numKeys; i < 2*numKeys; i++)
 +            execute("UPDATE %s SET properties = properties + ? WHERE userid = 'user'", set("prop_" + Integer.toString(i)));
 +
 +        flush();
 +
 +        Object[][] rows = getRows(execute("SELECT properties from %s where userid = 'user'"));
 +        assertEquals(1, rows.length);
 +        assertEquals(numKeys * 2, ((Set) rows[0][0]).size());
 +    }
++
+     @Test
+     public void testUpdateStaticList() throws Throwable
+     {
+         createTable("CREATE TABLE %s (k1 text, k2 text, s_list list<int> static, PRIMARY KEY (k1, k2))");
+ 
+         execute("insert into %s (k1, k2) VALUES ('a','b')");
+         execute("update %s set s_list = s_list + [0] where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+ 
+         execute("update %s set s_list[0] = 100 where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(100)));
+ 
+         execute("update %s set s_list = s_list + [0] where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(100, 0)));
+ 
+         execute("delete s_list[0] from %s where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+     }
 -
  }


[2/5] cassandra git commit: Fix update/delete behavior for static lists

Posted by bl...@apache.org.
Fix update/delete behavior for static lists

patch by Brett Snyder; reviewed by Benjamin Lerer for CASSANDRA-9838


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/21065423
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/21065423
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/21065423

Branch: refs/heads/trunk
Commit: 21065423c6ce5a92194994bfa9e441d1d2b86b0a
Parents: 04e789b
Author: Brett Snyder <bs...@gmail.com>
Authored: Wed Sep 9 21:49:14 2015 +0200
Committer: blerer <be...@datastax.com>
Committed: Wed Sep 9 21:49:14 2015 +0200

----------------------------------------------------------------------
 .../cql3/statements/ModificationStatement.java  |  6 ++++-
 .../validation/entities/CollectionsTest.java    | 23 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/21065423/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index 876c5e4..37b46ae 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -29,6 +29,7 @@ import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.composites.AbstractCellNameType;
 import org.apache.cassandra.db.composites.CBuilder;
 import org.apache.cassandra.db.composites.Composite;
 import org.apache.cassandra.db.filter.ColumnSlice;
@@ -446,7 +447,10 @@ public abstract class ModificationStatement implements CQLStatement
             if (row.cf == null || row.cf.isEmpty())
                 continue;
 
-            Iterator<CQL3Row> iter = cfm.comparator.CQL3RowBuilder(cfm, now).group(row.cf.getSortedColumns().iterator());
+            CQL3Row.RowIterator iter = cfm.comparator.CQL3RowBuilder(cfm, now).group(row.cf.getSortedColumns().iterator());
+            if(iter.getStaticRow() != null) {
+                map.put(row.key.getKey(), iter.getStaticRow());
+            }
             if (iter.hasNext())
             {
                 map.put(row.key.getKey(), iter.next());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/21065423/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
index 0241d4f..31dd5a6 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
@@ -485,4 +485,27 @@ public class CollectionsTest extends CQLTester
         assertInvalid("alter table %s add v set<int>");
     }
 
+
+    /**
+     * Test for 9838.
+     */
+    @Test
+    public void testUpdateStaticList() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 text, k2 text, s_list list<int> static, PRIMARY KEY (k1, k2))");
+
+        execute("insert into %s (k1, k2) VALUES ('a','b')");
+        execute("update %s set s_list = s_list + [0] where k1='a'");
+        assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+
+        execute("update %s set s_list[0] = 100 where k1='a'");
+        assertRows(execute("select s_list from %s where k1='a'"), row(list(100)));
+
+        execute("update %s set s_list = s_list + [0] where k1='a'");
+        assertRows(execute("select s_list from %s where k1='a'"), row(list(100, 0)));
+
+        execute("delete s_list[0] from %s where k1='a'");
+        assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+    }
+
 }


[3/5] cassandra git commit: Merge branch cassandra-2.1 into cassandra-2.2

Posted by bl...@apache.org.
Merge branch cassandra-2.1 into cassandra-2.2


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ec4b4d44
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ec4b4d44
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ec4b4d44

Branch: refs/heads/trunk
Commit: ec4b4d4467a90a50c645a26b5a7817f3c4d25cf4
Parents: 7b083a4 2106542
Author: blerer <be...@datastax.com>
Authored: Wed Sep 9 22:05:42 2015 +0200
Committer: blerer <be...@datastax.com>
Committed: Wed Sep 9 22:11:58 2015 +0200

----------------------------------------------------------------------
 .../cql3/statements/ModificationStatement.java  |  5 ++++-
 .../validation/entities/CollectionsTest.java    | 22 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ec4b4d44/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ec4b4d44/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
index 2e72c39,31dd5a6..6266fe7
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
@@@ -585,4 -485,27 +585,26 @@@ public class CollectionsTest extends CQ
          assertInvalid("alter table %s add v set<int>");
      }
  
 -
+     /**
+      * Test for 9838.
+      */
+     @Test
+     public void testUpdateStaticList() throws Throwable
+     {
+         createTable("CREATE TABLE %s (k1 text, k2 text, s_list list<int> static, PRIMARY KEY (k1, k2))");
+ 
+         execute("insert into %s (k1, k2) VALUES ('a','b')");
+         execute("update %s set s_list = s_list + [0] where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+ 
+         execute("update %s set s_list[0] = 100 where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(100)));
+ 
+         execute("update %s set s_list = s_list + [0] where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(100, 0)));
+ 
+         execute("delete s_list[0] from %s where k1='a'");
+         assertRows(execute("select s_list from %s where k1='a'"), row(list(0)));
+     }
+ 
  }