cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [8/20] git commit: add auto_snapshot option allowing disabling snapshot before drop/truncate patch by dbrosius; reviewed by jbellis for CASSANDRA-3710
Date Wed, 11 Apr 2012 14:13:27 GMT
add auto_snapshot option allowing disabling snapshot before drop/truncate
patch by dbrosius; reviewed by jbellis for CASSANDRA-3710


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

Branch: refs/heads/cassandra-1.1
Commit: 142e8c1a2967947a3ed5314e4577f4be3cfe4bd3
Parents: 9b746da
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Apr 11 09:01:56 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Apr 11 09:01:56 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    2 ++
 conf/cassandra.yaml                                |    6 ++++++
 src/java/org/apache/cassandra/config/Config.java   |    1 +
 .../cassandra/config/DatabaseDescriptor.java       |    4 ++++
 .../org/apache/cassandra/db/ColumnFamilyStore.java |    3 ++-
 .../cassandra/db/migration/DropColumnFamily.java   |    3 ++-
 .../cassandra/db/migration/DropKeyspace.java       |    4 +++-
 7 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/142e8c1a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1349299..e2fc4de 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 1.0.10
+ * add auto_snapshot option allowing disabling snapshot before drop/truncate
+   (CASSANDRA-3710)
  * allow short snitch names (CASSANDRA-4130)
  * cqlsh: guess correct version of Python for Arch Linux (CASSANDRA-4090)
  * (CLI) properly handle quotes in create/update keyspace commands (CASSANDRA-4129)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/142e8c1a/conf/cassandra.yaml
----------------------------------------------------------------------
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index 207d8f9..3249747 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -256,6 +256,12 @@ incremental_backups: false
 # is a data format change.
 snapshot_before_compaction: false
 
+# Whether or not a snapshot is taken of the data before keyspace truncation
+# or dropping of column families. The STRONGLY advised default of true 
+# should be used to provide data safety. If you set this flag to false, you will
+# lose data on truncation or drop.
+auto_snapshot: true
+
 # Add column indexes to a row after its contents reach this size.
 # Increase if your column values are large, or if you have a very large
 # number of columns.  The competing causes are, Cassandra has to

http://git-wip-us.apache.org/repos/asf/cassandra/blob/142e8c1a/src/java/org/apache/cassandra/config/Config.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java
index 7cff37f..e079590 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -80,6 +80,7 @@ public class Config
     public Integer thrift_max_message_length_in_mb = 16;
     public Integer thrift_framed_transport_size_in_mb = 15;
     public Boolean snapshot_before_compaction = false;
+    public Boolean auto_snapshot = true;
 
     /* if the size of columns or super-columns are more than this, indexing will kick in
*/
     public Integer column_index_size_in_kb = 64;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/142e8c1a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 667c90a..09686d2 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -900,6 +900,10 @@ public class DatabaseDescriptor
         return conf.snapshot_before_compaction;
     }
 
+    public static boolean isAutoSnapshot() {
+        return conf.auto_snapshot;
+    }
+
     public static boolean isAutoBootstrap()
     {
         return conf.auto_bootstrap;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/142e8c1a/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 9c790ae..b7d74bc 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1653,7 +1653,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
             throw new AssertionError(e);
         }
         long truncatedAt = System.currentTimeMillis();
-        snapshot(Table.getTimestampedSnapshotName(columnFamily));
+        if (DatabaseDescriptor.isAutoSnapshot())
+            snapshot(Table.getTimestampedSnapshotName(columnFamily));
 
         return CompactionManager.instance.submitTruncate(this, truncatedAt);
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/142e8c1a/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java b/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
index aec2722..af0ac9a 100644
--- a/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
+++ b/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
@@ -78,7 +78,8 @@ public class DropColumnFamily extends Migration
 
         if (!StorageService.instance.isClientMode())
         {
-            cfs.snapshot(Table.getTimestampedSnapshotName(cfs.columnFamily));
+            if (DatabaseDescriptor.isAutoSnapshot())
+                cfs.snapshot(Table.getTimestampedSnapshotName(cfs.columnFamily));
 
             CompactionManager.instance.getCompactionLock().lock();
             cfs.flushLock.lock();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/142e8c1a/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/migration/DropKeyspace.java b/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
index f434aaa..61852f5 100644
--- a/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
+++ b/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
@@ -60,7 +60,9 @@ public class DropKeyspace extends Migration
                 schema.purge(cfm);
                 if (!StorageService.instance.isClientMode())
                 {
-                    cfs.snapshot(snapshotName);
+                    if (DatabaseDescriptor.isAutoSnapshot())
+                        cfs.snapshot(snapshotName);
+
                     cfs.flushLock.lock();
                     try
                     {


Mime
View raw message