geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject geode git commit: The CCPTimer is now purged for every 1000 cancels done. Now uses internalSuspend in two places the previously used suspend. Since internalSuspend does not schedule a timer task these places will have no more issues with leaking memory.
Date Wed, 05 Apr 2017 23:53:40 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2485 [created] 9f5e394f5


The CCPTimer is now purged for every 1000 cancels done.
Now uses internalSuspend in two places the previously used
suspend. Since internalSuspend does not schedule a timer task
these places will have no more issues with leaking memory.


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

Branch: refs/heads/feature/GEODE-2485
Commit: 9f5e394f57038d03e93c4507414535c244f4597f
Parents: 39c72b2
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Wed Apr 5 16:51:29 2017 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed Apr 5 16:51:29 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/cache/DistributedRegion.java  |  6 +++---
 .../geode/internal/cache/GemFireCacheImpl.java   | 19 +++++++++++++++++++
 .../geode/internal/cache/TXManagerImpl.java      |  5 ++++-
 .../org/apache/geode/internal/cache/TXState.java |  4 ++--
 .../cache/tier/sockets/CacheClientProxy.java     |  8 ++++++--
 5 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9f5e394f/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
index fa02574..08c0b10 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
@@ -3949,7 +3949,7 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
   protected VersionTag fetchRemoteVersionTag(Object key) {
     VersionTag tag = null;
     assert this.dataPolicy != DataPolicy.REPLICATE;
-    TransactionId txId = cache.getCacheTransactionManager().suspend();
+    final TXStateProxy tx = cache.getTXMgr().internalSuspend();
     try {
       boolean retry = true;
       InternalDistributedMember member = getRandomReplicate();
@@ -3971,8 +3971,8 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
         }
       }
     } finally {
-      if (txId != null) {
-        cache.getCacheTransactionManager().resume(txId);
+      if (tx != null) {
+        cache.getTXMgr().resume(tx);
       }
     }
     return tag;

http://git-wip-us.apache.org/repos/asf/geode/blob/9f5e394f/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 1575517..8c1e30b 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -3936,6 +3936,25 @@ public class GemFireCacheImpl
     }
   }
 
+  private static final int PURGE_INTERVAL = 1000;
+  private int cancelCount = 0;
+
+  /**
+   * Does a periodic purge of the CCPTimer to prevent a large number of cancelled tasks from
+   * building up in it. See GEODE-2485.
+   */
+  public void purgeCCPTimer() {
+    synchronized (ccpTimerMutex) {
+      if (ccpTimer != null) {
+        cancelCount++;
+        if (cancelCount == PURGE_INTERVAL) {
+          cancelCount = 0;
+          ccpTimer.timerPurge();
+        }
+      }
+    }
+  }
+
   /**
    * @see LocalRegion
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/9f5e394f/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java
index 14fdf99..e8edfda 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXManagerImpl.java
@@ -690,7 +690,10 @@ public class TXManagerImpl implements CacheTransactionManager, MembershipListene
       tx.resume();
       SystemTimerTask task = this.expiryTasks.remove(tx.getTransactionId());
       if (task != null) {
-        task.cancel();
+        if (task.cancel()) {
+          GemFireCacheImpl cache = (GemFireCacheImpl) this.cache;
+          cache.purgeCCPTimer();
+        }
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/9f5e394f/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java b/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java
index d577f39..11786b0 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXState.java
@@ -1679,11 +1679,11 @@ public class TXState implements TXStateInterface {
       if (!pr.getBucketPrimary(curr.getBucketId()).equals(pr.cache.getMyId())) {
         // to fix bug 47893 suspend the tx before calling nonTXGetEntry
         final TXManagerImpl txmgr = pr.getGemFireCache().getTXMgr();
-        TransactionId tid = txmgr.suspend();
+        final TXStateProxy tx = txmgr.internalSuspend();
         try {
           return pr.nonTXGetEntry(curr, false, allowTombstones);
         } finally {
-          txmgr.resume(tid);
+          txmgr.resume(tx);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/9f5e394f/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
index d7b923c..3b0c2ff 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
@@ -1970,7 +1970,9 @@ public class CacheClientProxy implements ClientSession {
          */
         Object task = _durableExpirationTask.getAndSet(null);
         if (task != null) {
-          ((SystemTimerTask) task).cancel();
+          if (((SystemTimerTask) task).cancel()) {
+            _cache.purgeCCPTimer();
+          }
         }
       }
 
@@ -1988,7 +1990,9 @@ public class CacheClientProxy implements ClientSession {
             LocalizedStrings.CacheClientProxy_0_CANCELLING_EXPIRATION_TASK_SINCE_THE_CLIENT_HAS_RECONNECTED,
             this));
       }
-      task.cancel();
+      if (task.cancel()) {
+        _cache.purgeCCPTimer();
+      }
     }
   }
 


Mime
View raw message