cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [2/3] cassandra git commit: Avoid locks when checking LCS fanout and if we should do read-time defragmentation
Date Tue, 10 Oct 2017 11:00:23 GMT
Avoid locks when checking LCS fanout and if we should do read-time defragmentation

Patch by marcuse; reviewed by Jeff Jirsa for CASSANDRA-13930


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

Branch: refs/heads/trunk
Commit: f3cf1c019e0298dd04f6a0d7396b5fe4a93e6f9a
Parents: 3d09901
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Tue Oct 3 10:27:32 2017 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Tue Oct 10 12:49:01 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../compaction/CompactionStrategyManager.java   | 30 +++++---------------
 2 files changed, 8 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f3cf1c01/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 879397b..81444d2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.11.2
+ * Avoid locks when checking LCS fanout and if we should defrag (CASSANDRA-13930)
 Merged from 3.0:
  * Mishandling of cells for removed/dropped columns when reading legacy files (CASSANDRA-13939)
  * Deserialise sstable metadata in nodetool verify (CASSANDRA-13922)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f3cf1c01/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
index df89e53..94def2a 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
@@ -81,6 +81,8 @@ public class CompactionStrategyManager implements INotificationConsumer
      */
     private volatile CompactionParams schemaCompactionParams;
     private Directories.DataDirectory[] locations;
+    private boolean shouldDefragment;
+    private int fanout;
 
     public CompactionStrategyManager(ColumnFamilyStore cfs)
     {
@@ -92,6 +94,7 @@ public class CompactionStrategyManager implements INotificationConsumer
         params = cfs.metadata.params.compaction;
         locations = getDirectories().getWriteableLocations();
         enabled = params.isEnabled();
+
     }
 
     /**
@@ -182,6 +185,8 @@ public class CompactionStrategyManager implements INotificationConsumer
             }
             repaired.forEach(AbstractCompactionStrategy::startup);
             unrepaired.forEach(AbstractCompactionStrategy::startup);
+            shouldDefragment = repaired.get(0).shouldDefragment();
+            fanout = (repaired.get(0) instanceof LeveledCompactionStrategy) ? ((LeveledCompactionStrategy)
repaired.get(0)).getLevelFanoutSize() : LeveledCompactionStrategy.DEFAULT_LEVEL_FANOUT_SIZE;
         }
         finally
         {
@@ -343,19 +348,7 @@ public class CompactionStrategyManager implements INotificationConsumer
 
     public int getLevelFanoutSize()
     {
-        readLock.lock();
-        try
-        {
-            if (repaired.get(0) instanceof LeveledCompactionStrategy)
-            {
-                return ((LeveledCompactionStrategy) repaired.get(0)).getLevelFanoutSize();
-            }
-        }
-        finally
-        {
-            readLock.unlock();
-        }
-        return LeveledCompactionStrategy.DEFAULT_LEVEL_FANOUT_SIZE;
+        return fanout;
     }
 
     public int[] getSSTableCountPerLevel()
@@ -403,16 +396,7 @@ public class CompactionStrategyManager implements INotificationConsumer
 
     public boolean shouldDefragment()
     {
-        readLock.lock();
-        try
-        {
-            assert repaired.get(0).getClass().equals(unrepaired.get(0).getClass());
-            return repaired.get(0).shouldDefragment();
-        }
-        finally
-        {
-            readLock.unlock();
-        }
+        return shouldDefragment;
     }
 
     public Directories getDirectories()


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


Mime
View raw message