Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B5F691878F for ; Thu, 9 Jul 2015 12:08:16 +0000 (UTC) Received: (qmail 74903 invoked by uid 500); 9 Jul 2015 12:08:16 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 74873 invoked by uid 500); 9 Jul 2015 12:08:16 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 74864 invoked by uid 99); 9 Jul 2015 12:08:16 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2015 12:08:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 372B71A6C6A for ; Thu, 9 Jul 2015 12:08:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id VlKPf03o53wS for ; Thu, 9 Jul 2015 12:08:02 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 178184C0EA for ; Thu, 9 Jul 2015 12:07:54 +0000 (UTC) Received: (qmail 73131 invoked by uid 99); 9 Jul 2015 12:07:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2015 12:07:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5C995E6831; Thu, 9 Jul 2015 12:07:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ivasilinets@apache.org To: commits@ignite.incubator.apache.org Date: Thu, 09 Jul 2015 12:08:12 -0000 Message-Id: <542904dc3a0c4331b7504826c13ee0e8@git.apache.org> In-Reply-To: <94bdbb64e7004483ab43ec9a6836db4c@git.apache.org> References: <94bdbb64e7004483ab43ec9a6836db4c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [20/50] incubator-ignite git commit: ignite-1070 Zombie entries in cache with SortedEvictionPolicy ignite-1070 Zombie entries in cache with SortedEvictionPolicy Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9d0aa6f1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9d0aa6f1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9d0aa6f1 Branch: refs/heads/ignite-1087 Commit: 9d0aa6f1244e13187b64dec81b8d33d94f3db2af Parents: 44506c3 Author: agura Authored: Tue Jul 7 14:49:13 2015 +0300 Committer: agura Committed: Tue Jul 7 14:49:13 2015 +0300 ---------------------------------------------------------------------- .../cache/eviction/fifo/FifoEvictionPolicy.java | 5 ----- .../cache/eviction/lru/LruEvictionPolicy.java | 5 ----- .../eviction/sorted/SortedEvictionPolicy.java | 19 +++++-------------- ...cheConcurrentEvictionConsistencySelfTest.java | 15 +++++++++++++-- 4 files changed, 18 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d0aa6f1/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java index 221bc39..1e06ffd 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java @@ -216,11 +216,6 @@ public class FifoEvictionPolicy implements EvictionPolicy, FifoEvict // If node was unlinked by concurrent shrink() call, we must repeat the whole cycle. else if (!entry.removeMeta(node)) return false; - else { - memSize.add(-entry.size()); - - return true; - } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d0aa6f1/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java index 0be26c8..ba6f88a 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java @@ -200,11 +200,6 @@ public class LruEvictionPolicy implements EvictionPolicy, LruEvictio // If node was unlinked by concurrent shrink() call, we must repeat the whole cycle. else if (!entry.removeMeta(node)) return false; - else { - memSize.add(-entry.size()); - - return true; - } } } else if (queue.unlinkx(node)) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d0aa6f1/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java index b8b82fa..d99b3b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java @@ -224,21 +224,17 @@ public class SortedEvictionPolicy implements EvictionPolicy, SortedE private boolean touch(EvictableEntry entry) { Holder holder = entry.meta(); - // Entry has not been add yet to backed queue.. + // Entry has not been added yet to backed queue. if (holder == null) { while (true) { holder = new Holder<>(entry, orderCnt.incrementAndGet()); - set.add(holder); + if (entry.putMetaIfAbsent(holder) != null) + return false; // Set has not been changed. - if (entry.putMetaIfAbsent(holder) != null) { - // Was concurrently added, need to remove it from queue. - removeHolder(holder); + set.add(holder); - // Set has not been changed. - return false; - } - else if (holder.order > 0) { + if (holder.order > 0) { if (!entry.isCached()) { // Was concurrently evicted, need to remove it from queue. removeHolder(holder); @@ -253,11 +249,6 @@ public class SortedEvictionPolicy implements EvictionPolicy, SortedE // If holder was removed by concurrent shrink() call, we must repeat the whole cycle. else if (!entry.removeMeta(holder)) return false; - else { - memSize.add(-entry.size()); - - return true; - } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d0aa6f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java index 921422e..91e9ecc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java @@ -24,6 +24,7 @@ import org.apache.ignite.cache.eviction.lru.*; import org.apache.ignite.cache.eviction.sorted.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; @@ -273,15 +274,25 @@ public class GridCacheConcurrentEvictionConsistencySelfTest extends GridCommonAb info("Test results [threadCnt=" + threadCnt + ", iterCnt=" + ITERATION_CNT + ", cacheSize=" + cache.size() + ", internalQueueSize" + queue.size() + ", duration=" + (System.currentTimeMillis() - start) + ']'); + boolean detached = false; + for (Cache.Entry e : queue) { Integer rmv = cache.getAndRemove(e.getKey()); - if (rmv == null) - fail("Eviction policy contains key that is not present in cache: " + e); + CacheEvictableEntryImpl unwrapped = e.unwrap(CacheEvictableEntryImpl.class); + + if (rmv == null && (unwrapped.meta() != null || unwrapped.isCached())) { + U.warn(log, "Detached entry: " + e); + + detached = true; + } else info("Entry removed: " + rmv); } + if (detached) + fail("Eviction policy contains keys that are not present in cache"); + if (!(cache.localSize() == 0)) { boolean zombies = false;