cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [1/6] cassandra git commit: Fix startup problems due to schema tables not completely flushed
Date Fri, 07 Apr 2017 00:52:10 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 6efb44b3a -> 6991556e4
  refs/heads/cassandra-3.11 bfdc1e0fd -> ab1310b78
  refs/heads/trunk c794d2bed -> 9ed04da0c


Fix startup problems due to schema tables not completely flushed

patch by Stefania Alborghetti; reviewed by Aleksey Yeschenko for CASSANDRA-12213.


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

Branch: refs/heads/cassandra-3.0
Commit: 6991556e431a51575744248a4c484270c4f918c9
Parents: 6efb44b
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Wed Feb 22 11:33:03 2017 +0000
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Thu Apr 6 10:14:35 2017 +0800

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/schema/SchemaKeyspace.java | 22 +++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6991556e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8bd21bc..212c738 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.13
+ * Fix startup problems due to schema tables not completely flushed (CASSANDRA-12213)
  * Fix view builder bug that can filter out data on restart (CASSANDRA-13405)
  * Fix 2i page size calculation when there are no regular columns (CASSANDRA-13400)
  * Fix the conversion of 2.X expired rows without regular column data (CASSANDRA-13395)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6991556e/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
index eee4fbb..e860c59 100644
--- a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
+++ b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
@@ -25,8 +25,7 @@ import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.MapDifference;
+import com.google.common.collect.*;
 import com.google.common.collect.Maps;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -82,8 +81,21 @@ public final class SchemaKeyspace
     public static final String AGGREGATES = "aggregates";
     public static final String INDEXES = "indexes";
 
-    public static final List<String> ALL =
-        ImmutableList.of(KEYSPACES, TABLES, COLUMNS, DROPPED_COLUMNS, TRIGGERS, VIEWS, TYPES,
FUNCTIONS, AGGREGATES, INDEXES);
+    /**
+     * The order in this list matters.
+     *
+     * When flushing schema tables, we want to flush them in a way that mitigates the effects
of an abrupt shutdown whilst
+     * the tables are being flushed. On startup, we load the schema from disk before replaying
the CL, so we need to
+     * try to avoid problems like reading a table without columns or types, for example.
So columns and types should be
+     * flushed before tables, which should be flushed before keyspaces.
+     *
+     * When truncating, the order should be reversed. For immutable lists this is an efficient
operation that simply
+     * iterates in reverse order.
+     *
+     * See CASSANDRA-12213 for more details.
+     */
+    public static final ImmutableList<String> ALL =
+        ImmutableList.of(COLUMNS, DROPPED_COLUMNS, TRIGGERS, TYPES, FUNCTIONS, AGGREGATES,
INDEXES, TABLES, VIEWS, KEYSPACES);
 
     private static final CFMetaData Keyspaces =
         compile(KEYSPACES,
@@ -271,7 +283,7 @@ public final class SchemaKeyspace
 
     public static void truncate()
     {
-        ALL.forEach(table -> getSchemaCFS(table).truncateBlocking());
+        ALL.reverse().forEach(table -> getSchemaCFS(table).truncateBlocking());
     }
 
     static void flush()


Mime
View raw message