You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by gd...@apache.org on 2010/08/20 21:16:36 UTC

svn commit: r987605 - in /cassandra/trunk: CHANGES.txt NEWS.txt src/java/org/apache/cassandra/avro/CassandraDaemon.java src/java/org/apache/cassandra/db/SystemTable.java src/java/org/apache/cassandra/thrift/CassandraDaemon.java

Author: gdusbabek
Date: Fri Aug 20 19:16:35 2010
New Revision: 987605

URL: http://svn.apache.org/viewvc?rev=987605&view=rev
Log:
truncate hints if starting 0.7 for the first time. patch by gdusbabek, reviewed by jbellis. CASSANDRA-1414

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/NEWS.txt
    cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java
    cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=987605&r1=987604&r2=987605&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Fri Aug 20 19:16:35 2010
@@ -22,6 +22,7 @@ dev
  * disallow invalid keyspace and column family names. This includes name that
    matches a '^\w+' regex. (CASSANDRA-1377)
  * use JNA, if present, to take snapshots (CASSANDRA-1371)
+ * truncate hints if starting 0.7 for the first time (CASSANDRA-1414)
 
 
 0.7-beta1

Modified: cassandra/trunk/NEWS.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/NEWS.txt?rev=987605&r1=987604&r2=987605&view=diff
==============================================================================
--- cassandra/trunk/NEWS.txt (original)
+++ cassandra/trunk/NEWS.txt Fri Aug 20 19:16:35 2010
@@ -35,6 +35,10 @@ Upgrading
     The Cassandra inter-node protocol is incompatible with 0.6.x releases,
     meaning you will have to bring your cluster down prior to upgrading;
     you cannot mix 0.6 and 0.7 nodes.
+    
+    The hints schema was changed from 0.6 to 0.7. Cassandra automatically
+    snapshots and then truncates the hints column family as part of 
+    starting up 0.7 for the first time.
 
     Keyspace and ColumnFamily definitions are stored in the system
     keyspace, rather than the configuration file.

Modified: cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java?rev=987605&r1=987604&r2=987605&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java Fri Aug 20 19:16:35 2010
@@ -116,6 +116,8 @@ public class CassandraDaemon extends org
         {
             MigrationManager.applyMigrations(currentMigration, lastMigration);
         }
+        
+        SystemTable.purgeIncompatibleHints();
 
         // start server internals
         StorageService.instance.initServer();

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java?rev=987605&r1=987604&r2=987605&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java Fri Aug 20 19:16:35 2010
@@ -52,6 +52,7 @@ public class SystemTable
     private static final byte[] LOCATION_KEY = "L".getBytes(UTF_8);
     private static final byte[] BOOTSTRAP_KEY = "Bootstrap".getBytes(UTF_8);
     private static final byte[] GRAVEYARD_KEY = "Graveyard".getBytes(UTF_8);
+    private static final byte[] COOKIE_KEY = "Cookies".getBytes(UTF_8);
     private static final byte[] BOOTSTRAP = "B".getBytes(UTF_8);
     private static final byte[] TOKEN = "Token".getBytes(UTF_8);
     private static final byte[] GENERATION = "Generation".getBytes(UTF_8);
@@ -63,6 +64,25 @@ public class SystemTable
     {
         return StorageService.getPartitioner().decorateKey(key);
     }
+    
+    /* if hints become incompatible across versions of cassandra, that logic (and associated purging) is managed here. */
+    public static void purgeIncompatibleHints() throws IOException
+    {
+        // 0.6->0.7
+        final byte[] hintsPurged6to7 = "Hints purged as part of upgrading from 0.6.x to 0.7".getBytes();
+        Table table = Table.open(Table.SYSTEM_TABLE);
+        QueryFilter dotSeven = QueryFilter.getNamesFilter(decorate(COOKIE_KEY), new QueryPath(STATUS_CF), hintsPurged6to7);
+        ColumnFamily cf = table.getColumnFamilyStore(STATUS_CF).getColumnFamily(dotSeven);
+        if (cf == null)
+        {
+            // upgrading from 0.6 to 0.7.
+            logger.info("Upgrading to 0.7. Purging hints if there are any. Old hints will be snapshotted.");
+            new Truncation(Table.SYSTEM_TABLE, HintedHandOffManager.HINTS_CF).apply();
+            RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, COOKIE_KEY);
+            rm.add(new QueryPath(STATUS_CF, null, hintsPurged6to7), "oh yes, it they were purged.".getBytes(), new TimestampClock(System.currentTimeMillis()));
+            rm.apply();
+        }
+    }
 
     /**
      * Record token being used by another node

Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java?rev=987605&r1=987604&r2=987605&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java Fri Aug 20 19:16:35 2010
@@ -133,6 +133,8 @@ public class CassandraDaemon extends org
             MigrationManager.applyMigrations(currentMigration, lastMigration);
         }
         
+        SystemTable.purgeIncompatibleHints();
+        
         // start server internals
         StorageService.instance.initServer();