cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [4/7] git commit: Make upgradeSSTables skip current version sstables by default
Date Mon, 25 Mar 2013 19:21:25 GMT
Make upgradeSSTables skip current version sstables by default

patch by slebresne; reviewed by jbellis for CASSANDRA-5366


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

Branch: refs/heads/trunk
Commit: 37010e9d75c695d9e538873dadc3984e11eb3b25
Parents: 9250234
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Mar 25 20:07:02 2013 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Mar 25 20:07:02 2013 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 NEWS.txt                                           |   10 ++++++++++
 .../org/apache/cassandra/db/ColumnFamilyStore.java |    4 ++--
 .../cassandra/db/compaction/CompactionManager.java |    5 ++++-
 .../apache/cassandra/service/StorageService.java   |    4 ++--
 .../cassandra/service/StorageServiceMBean.java     |    2 +-
 src/java/org/apache/cassandra/tools/NodeCmd.java   |    5 ++++-
 src/java/org/apache/cassandra/tools/NodeProbe.java |    4 ++--
 .../org/apache/cassandra/tools/NodeToolHelp.yaml   |    5 +++--
 9 files changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 22cbe3a..8ad51a2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,7 @@
  * Validate that provided CQL3 collection value are < 64K (CASSANDRA-5355)
  * Change Kernel Page Cache skipping into row preheating (disabled by default)
    (CASSANDRA-4937)
+ * Make upgradeSSTable skip current version sstables by default (CASSANDRA-5366)
 Merged from 1.1:
  * cli: Quote ks and cf names in schema output when needed (CASSANDRA-5052)
  * Fix bad default for min/max timestamp in SSTableMetadata (CASSANDRA-5372)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 01db820..b53411b 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -8,6 +8,16 @@ upgrade, just in case you need to roll back to the previous version.
 (Cassandra version X + 1 will always be able to read data files created
 by version X, but the inverse is not necessarily the case.)
 
+1.2.4
+=====
+
+Upgrading
+---------
+    - 'nodetool upgradesstables' now only upgrade/rewrite sstables that are not
+      on the current version (which is usually what you want). Use the new -a
+      flag to recover the old behavior of rewriting all sstables.
+
+
 1.2.3
 =====
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index c14ffeb..642a404 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -975,9 +975,9 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         CompactionManager.instance.performScrub(ColumnFamilyStore.this);
     }
 
-    public void sstablesRewrite() throws ExecutionException, InterruptedException
+    public void sstablesRewrite(boolean excludeCurrentVersion) throws ExecutionException,
InterruptedException
     {
-        CompactionManager.instance.performSSTableRewrite(ColumnFamilyStore.this);
+        CompactionManager.instance.performSSTableRewrite(ColumnFamilyStore.this, excludeCurrentVersion);
     }
 
     public void markCompacted(Collection<SSTableReader> sstables, OperationType compactionType)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/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 0fe3a7a..db75bc1 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -265,7 +265,7 @@ public class CompactionManager implements CompactionManagerMBean
         });
     }
 
-    public void performSSTableRewrite(ColumnFamilyStore cfStore) throws InterruptedException,
ExecutionException
+    public void performSSTableRewrite(ColumnFamilyStore cfStore, final boolean excludeCurrentVersion)
throws InterruptedException, ExecutionException
     {
         performAllSSTableOperation(cfStore, new AllSSTablesOperation()
         {
@@ -273,6 +273,9 @@ public class CompactionManager implements CompactionManagerMBean
             {
                 for (final SSTableReader sstable : sstables)
                 {
+                    if (excludeCurrentVersion && sstable.descriptor.version.equals(Descriptor.Version.CURRENT))
+                        continue;
+
                     // SSTables are marked by the caller
                     // NOTE: it is important that the task create one and only one sstable,
even for Leveled compaction (see LeveledManifest.replace())
                     CompactionTask task = new CompactionTask(cfs, Collections.singletonList(sstable),
NO_GC);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 6e6f5ef..22696e9 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -2099,10 +2099,10 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
             cfStore.scrub();
     }
 
-    public void upgradeSSTables(String tableName, String... columnFamilies) throws IOException,
ExecutionException, InterruptedException
+    public void upgradeSSTables(String tableName, boolean excludeCurrentVersion, String...
columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
         for (ColumnFamilyStore cfStore : getValidColumnFamilies(true, true, tableName, columnFamilies))
-            cfStore.sstablesRewrite();
+            cfStore.sstablesRewrite(excludeCurrentVersion);
     }
 
     public void forceTableCompaction(String tableName, String... columnFamilies) throws IOException,
ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/src/java/org/apache/cassandra/service/StorageServiceMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
index aa0881b..b831d7d 100644
--- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java
+++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
@@ -242,7 +242,7 @@ public interface StorageServiceMBean extends NotificationEmitter
      * Rewrite all sstables to the latest version.
      * Unlike scrub, it doesn't skip bad rows and do not snapshot sstables first.
      */
-    public void upgradeSSTables(String tableName, String... columnFamilies) throws IOException,
ExecutionException, InterruptedException;
+    public void upgradeSSTables(String tableName, boolean excludeCurrentVersion, String...
columnFamilies) throws IOException, ExecutionException, InterruptedException;
 
     /**
      * Flush all memtables for the given column families, or all columnfamilies for the given
table

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index 9d113a6..b7ff504 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -67,6 +67,7 @@ public class NodeCmd
     private static final Pair<String, String> LOCAL_DC_REPAIR_OPT = Pair.create("local",
"in-local-dc");
     private static final Pair<String, String> START_TOKEN_OPT = Pair.create("st", "start-token");
     private static final Pair<String, String> END_TOKEN_OPT = Pair.create("et", "end-token");
+    private static final Pair<String, String> UPGRADE_ALL_SSTABLE_OPT = Pair.create("a",
"include-all-sstables");
 
     private static final String DEFAULT_HOST = "127.0.0.1";
     private static final int DEFAULT_PORT = 7199;
@@ -89,6 +90,7 @@ public class NodeCmd
         options.addOption(LOCAL_DC_REPAIR_OPT, false, "only repair against nodes in the same
datacenter");
         options.addOption(START_TOKEN_OPT, true, "token at which repair range starts");
         options.addOption(END_TOKEN_OPT, true, "token at which repair range ends");
+        options.addOption(UPGRADE_ALL_SSTABLE_OPT, false, "includes sstables that are already
on the most recent version during upgradesstables");
     }
 
     public NodeCmd(NodeProbe probe)
@@ -1403,7 +1405,8 @@ public class NodeCmd
                     catch (ExecutionException ee) { err(ee, "Error occurred while scrubbing
keyspace " + keyspace); }
                     break;
                 case UPGRADESSTABLES :
-                    try { probe.upgradeSSTables(keyspace, columnFamilies); }
+                    boolean excludeCurrentVersion = !cmd.hasOption(UPGRADE_ALL_SSTABLE_OPT.left);
+                    try { probe.upgradeSSTables(keyspace, excludeCurrentVersion, columnFamilies);
}
                     catch (ExecutionException ee) { err(ee, "Error occurred while upgrading
the sstables for keyspace " + keyspace); }
                     break;
                 default:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index ce4407f..2c4555d 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -192,9 +192,9 @@ public class NodeProbe
         ssProxy.scrub(tableName, columnFamilies);
     }
 
-    public void upgradeSSTables(String tableName, String... columnFamilies) throws IOException,
ExecutionException, InterruptedException
+    public void upgradeSSTables(String tableName, boolean excludeCurrentVersion, String...
columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
-        ssProxy.upgradeSSTables(tableName, columnFamilies);
+        ssProxy.upgradeSSTables(tableName, excludeCurrentVersion, columnFamilies);
     }
 
     public void forceTableCompaction(String tableName, String... columnFamilies) throws IOException,
ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37010e9d/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
----------------------------------------------------------------------
diff --git a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
index a67e1a3..1ac687d 100644
--- a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
+++ b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
@@ -136,9 +136,10 @@ commands:
   - name: scrub [keyspace] [cfnames]
     help: |
       Scrub (rebuild sstables for) one or more column families
-  - name: upgradesstables [keyspace] [cfnames]
+  - name: upgradesstables [-a|--include-all-sstables] [keyspace] [cfnames]
     help: |
-      Scrub (rebuild sstables for) one or more column families
+      Rewrite sstables (for the requested column families) that are not on the current version
(thus upgrading them to said current version).
+      Use -a to include all sstables, even those already on the current version.
   - name: setcompactionthreshold <keyspace> <cfname>
     help: |
       Set min and max compaction thresholds for a given column family


Mime
View raw message