This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
     new 0e12b8d  Don't take snapshots when truncating system tables
0e12b8d is described below

commit 0e12b8d4fc9183cb8bb37cb461c3fe9e434ba9b8
Author: Brandon Williams <brandonwilli...@apache.org>
AuthorDate: Fri Oct 8 10:52:11 2021 -0500

    Don't take snapshots when truncating system tables
    
    Patch by brandonwilliams; reviewed by adelapena and blerer for 
CASSANDRA-16839
---
 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java | 17 ++++++++++++++---
 src/java/org/apache/cassandra/db/SystemKeyspace.java    |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 2ca4481..ae88aaa 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.26:
+ * Don't take snapshots when truncating system tables (CASSANDRA-16839)
  * Make -Dtest.methods consistently optional in all Ant test targets 
(CASSANDRA-17014)
  * Immediately apply stream throughput, considering negative values as 
unthrottled (CASSANDRA-16959)
  * Do not release new SSTables in offline transactions (CASSANDRA-16975)
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java 
b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 405aec7..e7c1868 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2035,10 +2035,21 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
         }
     }
 
+    public void truncateBlocking()
+    {
+        truncateBlocking(false);
+    }
+
+    public void truncateBlockingWithoutSnapshot()
+    {
+        truncateBlocking(true);
+    }
+
     /**
      * Truncate deletes the entire column family's data with no expensive 
tombstone creation
+     * @param noSnapshot if {@code true} no snapshot will be taken
      */
-    public void truncateBlocking()
+    private void truncateBlocking(boolean noSnapshot)
     {
         // We have two goals here:
         // - truncate should delete everything written before truncate was 
invoked
@@ -2059,7 +2070,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
         final long truncatedAt;
         final ReplayPosition replayAfter;
 
-        if (keyspace.getMetadata().params.durableWrites || 
DatabaseDescriptor.isAutoSnapshot())
+        if (!noSnapshot && (keyspace.getMetadata().params.durableWrites || 
DatabaseDescriptor.isAutoSnapshot()))
         {
             replayAfter = forceBlockingFlush();
             viewManager.forceBlockingFlush();
@@ -2089,7 +2100,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
             logger.debug("Discarding sstable data for truncated CF + indexes");
             data.notifyTruncated(truncatedAt);
 
-            if (DatabaseDescriptor.isAutoSnapshot())
+            if (!noSnapshot && DatabaseDescriptor.isAutoSnapshot())
                 snapshot(Keyspace.getTimestampedSnapshotName(name));
 
             discardSSTables(truncatedAt);
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java 
b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index 7fd9268..dc550df 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -1347,7 +1347,7 @@ public final class SystemKeyspace
     public static void resetAvailableRanges()
     {
         ColumnFamilyStore availableRanges = 
Keyspace.open(NAME).getColumnFamilyStore(AVAILABLE_RANGES);
-        availableRanges.truncateBlocking();
+        availableRanges.truncateBlockingWithoutSnapshot();
     }
 
     /**

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to