Persist local metadata in SystemKeyspace earlier in initialization sequence

Patch by Joel Knighton; reviewed by Sam Tunnicliffe for CASSANDRA-11742


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

Branch: refs/heads/cassandra-3.7
Commit: 360541f16a158f560d7cce1fcc264e246a80d10f
Parents: bb88b8c
Author: Joel Knighton <joel.knigh...@datastax.com>
Authored: Tue May 24 12:07:41 2016 -0500
Committer: Sam Tunnicliffe <s...@beobal.com>
Committed: Fri Jun 3 10:29:52 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                | 1 +
 src/java/org/apache/cassandra/db/SystemKeyspace.java       | 3 +--
 src/java/org/apache/cassandra/service/CassandraDaemon.java | 4 ++++
 3 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/360541f1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9752d16..ce48994 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.7
+ * Persist local metadata earlier in startup sequence (CASSANDRA-11742)
  * Run CommitLog tests with different compression settings (CASSANDRA-9039)
  * cqlsh: fix tab completion for case-sensitive identifiers (CASSANDRA-11664)
  * Avoid showing estimated key as -1 in tablestats (CASSANDRA-11587)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/360541f1/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java 
b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index 1ce599d..74a3c7b 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -294,11 +294,10 @@ public final class SystemKeyspace
 
     public static void finishStartup()
     {
-        persistLocalMetadata();
         LegacySchemaTables.saveSystemKeyspaceSchema();
     }
 
-    private static void persistLocalMetadata()
+    public static void persistLocalMetadata()
     {
         String req = "INSERT INTO system.%s (" +
                      "key," +

http://git-wip-us.apache.org/repos/asf/cassandra/blob/360541f1/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java 
b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index 1e9378b..6129928 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -177,6 +177,10 @@ public class CassandraDaemon
             exitOrFail(3, e.getMessage(), e.getCause());
         }
 
+        // We need to persist this as soon as possible after startup checks.
+        // This should be the first write to SystemKeyspace (CASSANDRA-11742)
+        SystemKeyspace.persistLocalMetadata();
+
         maybeInitJmx();
 
         Thread.setDefaultUncaughtExceptionHandler(new 
Thread.UncaughtExceptionHandler()

Reply via email to