Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.11 62e46f719 -> fe0ee85c7
  refs/heads/trunk ee907a321 -> 7a29d22e6


Acquire read lock before accessing CompactionStrategyManager fields

Patch by Paulo Motta; Reviewed by Marcus Eriksson for CASSANDRA-14139


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

Branch: refs/heads/cassandra-3.11
Commit: fe0ee85c71faada0acb48a65f249575c65bf0972
Parents: 62e46f7
Author: Paulo Motta <[email protected]>
Authored: Sat Dec 30 02:10:35 2017 +1100
Committer: Paulo Motta <[email protected]>
Committed: Wed Jan 10 18:39:12 2018 -0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../compaction/CompactionStrategyManager.java   | 47 ++++++++++++++------
 2 files changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fe0ee85c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d6d8066..b89ad99 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.11.2
+ * Acquire read lock before accessing CompactionStrategyManager fields 
(CASSANDRA-14139)
  * Split CommitLogStressTest to avoid timeout (CASSANDRA-14143)
  * Avoid invalidating disk boundaries unnecessarily (CASSANDRA-14083)
  * Avoid exposing compaction strategy index externally (CASSANDRA-14082)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fe0ee85c/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 39d253b..a50f428 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
@@ -105,6 +105,7 @@ public class CompactionStrategyManager implements 
INotificationConsumer
      **/
     private volatile CompactionParams schemaCompactionParams;
     private boolean shouldDefragment;
+    private boolean supportsEarlyOpen;
     private int fanout;
 
     public CompactionStrategyManager(ColumnFamilyStore cfs)
@@ -216,6 +217,7 @@ public class CompactionStrategyManager implements 
INotificationConsumer
             repaired.forEach(AbstractCompactionStrategy::startup);
             unrepaired.forEach(AbstractCompactionStrategy::startup);
             shouldDefragment = repaired.get(0).shouldDefragment();
+            supportsEarlyOpen = repaired.get(0).supportsEarlyOpen();
             fanout = (repaired.get(0) instanceof LeveledCompactionStrategy) ? 
((LeveledCompactionStrategy) repaired.get(0)).getLevelFanoutSize() : 
LeveledCompactionStrategy.DEFAULT_LEVEL_FANOUT_SIZE;
         }
         finally
@@ -1037,35 +1039,52 @@ public class CompactionStrategyManager implements 
INotificationConsumer
 
     public boolean isRepaired(AbstractCompactionStrategy strategy)
     {
-        return repaired.contains(strategy);
+        readLock.lock();
+        try
+        {
+            return repaired.contains(strategy);
+        }
+        finally
+        {
+            readLock.unlock();
+        }
     }
 
     public List<String> getStrategyFolders(AbstractCompactionStrategy strategy)
     {
-        List<Directories.DataDirectory> locations = 
currentBoundaries.directories;
-        if (partitionSSTablesByTokenRange)
+        readLock.lock();
+        try
         {
-            int unrepairedIndex = unrepaired.indexOf(strategy);
-            if (unrepairedIndex > 0)
+            List<Directories.DataDirectory> locations = 
currentBoundaries.directories;
+            if (partitionSSTablesByTokenRange)
             {
-                return 
Collections.singletonList(locations.get(unrepairedIndex).location.getAbsolutePath());
+                int unrepairedIndex = unrepaired.indexOf(strategy);
+                if (unrepairedIndex > 0)
+                {
+                    return 
Collections.singletonList(locations.get(unrepairedIndex).location.getAbsolutePath());
+                }
+                int repairedIndex = repaired.indexOf(strategy);
+                if (repairedIndex > 0)
+                {
+                    return 
Collections.singletonList(locations.get(repairedIndex).location.getAbsolutePath());
+                }
             }
-            int repairedIndex = repaired.indexOf(strategy);
-            if (repairedIndex > 0)
+            List<String> folders = new ArrayList<>(locations.size());
+            for (Directories.DataDirectory location : locations)
             {
-                return 
Collections.singletonList(locations.get(repairedIndex).location.getAbsolutePath());
+                folders.add(location.location.getAbsolutePath());
             }
+            return folders;
         }
-        List<String> folders = new ArrayList<>(locations.size());
-        for (Directories.DataDirectory location : locations)
+        finally
         {
-            folders.add(location.location.getAbsolutePath());
+            readLock.unlock();
         }
-        return folders;
+
     }
 
     public boolean supportsEarlyOpen()
     {
-        return repaired.get(0).supportsEarlyOpen();
+        return supportsEarlyOpen;
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to