You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2015/06/17 18:12:09 UTC

[1/2] cassandra git commit: Fix memory leak in Ref due to ConcurrentLinkedQueue behaviour

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 514dcd944 -> 6068efbaf


Fix memory leak in Ref due to ConcurrentLinkedQueue behaviour

patch by benedict; reviewed by marcus for CASSANDRA-9549


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

Branch: refs/heads/cassandra-2.2
Commit: 7c5fc40b8b644e05c32479f2581309f75f981421
Parents: 46cc577
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Wed Jun 17 17:02:03 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 17 17:02:03 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 .../org/apache/cassandra/utils/concurrent/Ref.java   |  8 +++-----
 .../cassandra/utils/concurrent/RefCountedTest.java   | 15 +++++++++++++++
 3 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c5fc40b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5f9187c..009d974 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.7
+ * Fix memory leak in Ref due to ConcurrentLinkedQueue.remove() behaviour (CASSANDRA-9549)
 Merged from 2.0
  * Periodically submit background compaction tasks (CASSANDRA-9592)
  * Set HAS_MORE_PAGES flag to false when PagingState is null (CASSANDRA-9571)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c5fc40b/src/java/org/apache/cassandra/utils/concurrent/Ref.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/concurrent/Ref.java b/src/java/org/apache/cassandra/utils/concurrent/Ref.java
index 4e6cef7..f9876de 100644
--- a/src/java/org/apache/cassandra/utils/concurrent/Ref.java
+++ b/src/java/org/apache/cassandra/utils/concurrent/Ref.java
@@ -2,12 +2,10 @@ package org.apache.cassandra.utils.concurrent;
 
 import java.lang.ref.PhantomReference;
 import java.lang.ref.ReferenceQueue;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 
@@ -233,7 +231,7 @@ public final class Ref<T> implements RefCounted<T>, AutoCloseable
     {
         // we need to retain a reference to each of the PhantomReference instances
         // we are using to track individual refs
-        private final ConcurrentLinkedQueue<State> locallyExtant = new ConcurrentLinkedQueue<>();
+        private final Collection<State> locallyExtant = new ConcurrentLinkedDeque<>();
         // the number of live refs
         private final AtomicInteger counts = new AtomicInteger();
         // the object to call to cleanup when our refs are all finished with

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c5fc40b/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java b/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
index a9247cd..bb173fe 100644
--- a/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
+++ b/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
@@ -21,6 +21,7 @@ package org.apache.cassandra.utils.concurrent;
 import org.junit.Test;
 
 import junit.framework.Assert;
+import org.apache.cassandra.utils.ObjectSizes;
 
 public class RefCountedTest
 {
@@ -82,4 +83,18 @@ public class RefCountedTest
         {
         }
     }
+
+    @Test
+    public void testMemoryLeak()
+    {
+        Tidier tidier = new Tidier();
+        Ref<Object> ref = new Ref(null, tidier);
+        long initialSize = ObjectSizes.measureDeep(ref);
+        for (int i = 0 ; i < 1000 ; i++)
+            ref.ref().release();
+        long finalSize = ObjectSizes.measureDeep(ref);
+        if (finalSize > initialSize * 2)
+            throw new AssertionError();
+        ref.release();
+    }
 }


[2/2] cassandra git commit: Merge branch 'cassandra-2.1' into cassandra-2.2

Posted by be...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2

Conflicts:
	CHANGES.txt


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

Branch: refs/heads/cassandra-2.2
Commit: 6068efbaf43a18c6f9250638bece98010ce59100
Parents: 514dcd9 7c5fc40
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Wed Jun 17 17:08:07 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 17 17:08:07 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                          |  4 +++-
 .../org/apache/cassandra/utils/concurrent/Ref.java   |  8 +++-----
 .../cassandra/utils/concurrent/RefCountedTest.java   | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6068efba/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 9dccd84,009d974..3e9940c
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,38 -1,11 +1,40 @@@
 -2.1.7
 +2.2
 + * Fix connection leak in CqlRecordWriter (CASSANDRA-9576)
 + * Mlockall before opening system sstables & remove boot_without_jna option (CASSANDRA-9573)
 + * Add functions to convert timeuuid to date or time, deprecate dateOf and unixTimestampOf (CASSANDRA-9229)
 + * Make sure we cancel non-compacting sstables from LifecycleTransaction (CASSANDRA-9566)
 + * Fix deprecated repair JMX API (CASSANDRA-9570)
- Merged from 2.0:
++Merged from 2.1:
+  * Fix memory leak in Ref due to ConcurrentLinkedQueue.remove() behaviour (CASSANDRA-9549)
+ Merged from 2.0
   * Periodically submit background compaction tasks (CASSANDRA-9592)
   * Set HAS_MORE_PAGES flag to false when PagingState is null (CASSANDRA-9571)
 + * Add logback metrics (CASSANDRA-9378)
  
  
 -2.1.6
 +2.2.0-rc1
 + * Compressed commit log should measure compressed space used (CASSANDRA-9095)
 + * Fix comparison bug in CassandraRoleManager#collectRoles (CASSANDRA-9551)
 + * Add tinyint,smallint,time,date support for UDFs (CASSANDRA-9400)
 + * Deprecates SSTableSimpleWriter and SSTableSimpleUnsortedWriter (CASSANDRA-9546)
 + * Empty INITCOND treated as null in aggregate (CASSANDRA-9457)
 + * Remove use of Cell in Thrift MapReduce classes (CASSANDRA-8609)
 + * Integrate pre-release Java Driver 2.2-rc1, custom build (CASSANDRA-9493)
 + * Clean up gossiper logic for old versions (CASSANDRA-9370)
 + * Fix custom payload coding/decoding to match the spec (CASSANDRA-9515)
 + * ant test-all results incomplete when parsed (CASSANDRA-9463)
 + * Disallow frozen<> types in function arguments and return types for
 +   clarity (CASSANDRA-9411)
 + * Static Analysis to warn on unsafe use of Autocloseable instances (CASSANDRA-9431)
 + * Update commitlog archiving examples now that commitlog segments are
 +   not recycled (CASSANDRA-9350)
 + * Extend Transactional API to sstable lifecycle management (CASSANDRA-8568)
 + * (cqlsh) Add support for native protocol 4 (CASSANDRA-9399)
 + * Ensure that UDF and UDAs are keyspace-isolated (CASSANDRA-9409)
 + * Revert CASSANDRA-7807 (tracing completion client notifications) (CASSANDRA-9429)
 + * Add ability to stop compaction by ID (CASSANDRA-7207)
 + * Let CassandraVersion handle SNAPSHOT version (CASSANDRA-9438)
 +Merged from 2.1:
   * (cqlsh) Fix using COPY through SOURCE or -f (CASSANDRA-9083)
   * Fix occasional lack of `system` keyspace in schema tables (CASSANDRA-8487)
   * Use ProtocolError code instead of ServerError code for native protocol

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6068efba/src/java/org/apache/cassandra/utils/concurrent/Ref.java
----------------------------------------------------------------------