You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2016/05/05 22:05:07 UTC

[04/10] cassandra git commit: Avoid creating a snapshot at restart for compactions_in_progress

Avoid creating a snapshot at restart for compactions_in_progress

Patch by Alex Petrov; reviewed by Joel Knighton for CASSANDRA-10962


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

Branch: refs/heads/trunk
Commit: 5a923f65c2c02d08b687874dc8ac45d2d032b811
Parents: 5de9de1
Author: Alex Petrov <ol...@gmail.com>
Authored: Thu Apr 28 16:20:19 2016 +0200
Committer: Josh McKenzie <jo...@datastax.com>
Committed: Thu May 5 18:03:48 2016 -0400

----------------------------------------------------------------------
 .../org/apache/cassandra/db/ColumnFamilyStore.java  | 16 ++++++++++++++--
 .../org/apache/cassandra/db/SystemKeyspace.java     |  2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5a923f65/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 bb2b5c9..513a138 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2681,6 +2681,18 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
      */
     public void truncateBlocking()
     {
+        truncateBlocking(DatabaseDescriptor.isAutoSnapshot());
+    }
+
+    /**
+     * Truncate deletes the column family's data with no expensive tombstone creation,
+     * optionally snapshotting the data.
+     *
+     * @param takeSnapshot whether or not to take a snapshot <code>true</code> if snapshot should be taken,
+     *                     <code>false</code> otherwise
+     */
+    public void truncateBlocking(final boolean takeSnapshot)
+    {
         // We have two goals here:
         // - truncate should delete everything written before truncate was invoked
         // - but not delete anything that isn't part of the snapshot we create.
@@ -2695,7 +2707,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         // position in the System keyspace.
         logger.trace("truncating {}", name);
 
-        if (keyspace.getMetadata().durableWrites || DatabaseDescriptor.isAutoSnapshot())
+        if (keyspace.getMetadata().durableWrites || takeSnapshot)
         {
             // flush the CF being truncated before forcing the new segment
             forceBlockingFlush();
@@ -2724,7 +2736,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
                 final long truncatedAt = System.currentTimeMillis();
                 data.notifyTruncated(truncatedAt);
 
-                if (DatabaseDescriptor.isAutoSnapshot())
+                if (takeSnapshot)
                     snapshot(Keyspace.getTimestampedSnapshotName(name));
 
                 ReplayPosition replayAfter = discardSSTables(truncatedAt);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5a923f65/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 46de0db..1ce599d 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -402,7 +402,7 @@ public final class SystemKeyspace
     public static void discardCompactionsInProgress()
     {
         ColumnFamilyStore compactionLog = Keyspace.open(NAME).getColumnFamilyStore(COMPACTIONS_IN_PROGRESS);
-        compactionLog.truncateBlocking();
+        compactionLog.truncateBlocking(false);
     }
 
     public static void updateCompactionHistory(String ksname,