Return-Path: X-Original-To: apmail-ignite-user-archive@minotaur.apache.org Delivered-To: apmail-ignite-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C9F1A1822E for ; Thu, 31 Dec 2015 16:13:13 +0000 (UTC) Received: (qmail 51353 invoked by uid 500); 31 Dec 2015 16:13:13 -0000 Delivered-To: apmail-ignite-user-archive@ignite.apache.org Received: (qmail 51305 invoked by uid 500); 31 Dec 2015 16:13:13 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 51295 invoked by uid 99); 31 Dec 2015 16:13:13 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Dec 2015 16:13:13 +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 C344B1A0454 for ; Thu, 31 Dec 2015 16:13:12 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.92 X-Spam-Level: X-Spam-Status: No, score=0.92 tagged_above=-999 required=6.31 tests=[SPF_FAIL=0.919, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id w1xLIIOVsDau for ; Thu, 31 Dec 2015 16:13:04 +0000 (UTC) Received: from mbob.nabble.com (mbob.nabble.com [162.253.133.15]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 3CDF020CAF for ; Thu, 31 Dec 2015 16:13:04 +0000 (UTC) Received: from malf.nabble.com (unknown [162.253.133.59]) by mbob.nabble.com (Postfix) with ESMTP id 5DEFE1D222C1 for ; Thu, 31 Dec 2015 08:11:34 -0800 (PST) Date: Thu, 31 Dec 2015 08:02:43 -0800 (PST) From: kevin To: user@ignite.apache.org Message-ID: <1451577763215-2363.post@n6.nabble.com> Subject: Problem with cache expiry and lock MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I ran into a problem with using cache expiry and cache locks. In my event listener for the expiry, I acquire/release a lock on the key being expired. This works fine unless something else waits on the lock after I've acquired it, then they would be stuck in a deadlock. The follow code snippet should reproduce this problem. Should I not be trying to lock the cache object being expired in my listener? IgniteConfiguration igniteConfig = new IgniteConfiguration(); igniteConfig.setIncludeEventTypes(EventType.EVT_CACHE_OBJECT_EXPIRED); Ignite ignite = Ignition.start(igniteConfig); CacheConfiguration cfg = new CacheConfiguration<>(); cfg.setName("test1"); cfg.setCacheMode(CacheMode.PARTITIONED); cfg.setRebalanceMode(CacheRebalanceMode.SYNC); cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); IgniteCache cache1 = ignite.getOrCreateCache(cfg); IgniteCache cache2 = cache1.withExpiryPolicy( new AccessedExpiryPolicy(new Duration(TimeUnit.SECONDS, 1))); IgnitePredicate locallistener = (evt) -> { try { Lock lock = cache1.lock(evt.key()); lock.lock(); Thread.sleep(3000); // give some time for other thread to try to acquire lock /* -- critical section */ lock.unlock(); } catch (InterruptedException e) { e.printStackTrace(); } return true; }; ignite.events().localListen(locallistener, EventType.EVT_CACHE_OBJECT_EXPIRED); cache2.put(1, 1); Thread.sleep(2000); // wait for cache entry to expire and listener to run Lock lock = cache1.lock(1); lock.lock(); /* -- critical section */ lock.unlock(); -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Problem-with-cache-expiry-and-lock-tp2363.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.