This discussion is archived
1 Reply Latest reply: Oct 8, 2013 8:24 AM by 82420128-c6b8-49b4-9804-510cbc337b09 RSS

CacheLoader --  service thread(s) should not call ensureCache as this may result in deadlock. The most common case is a CacheFactory call from a custom CacheStore implementation.

82420128-c6b8-49b4-9804-510cbc337b09 Newbie
Currently Being Moderated

Hi Guys,

 

In my cache loader, am retrieving mutliple records(translating in to multiple (K,V)  pairs to be stored in cache)  from DB as opposed to retrieving only one record from the DB and returning the value, hence I need a way to do putAll() on the same cache on which cacheloader is triggered. I understand re-entrancy issue on Service thread, so am spawing new thread to do putAll() on the same cache in load() but I get following warning, since I calling CacheFactory in new Thread I shouldn't be seeing this warning. Rght?

 

Application code running on "TestDistributedCache" service thread(s) should not call ensureCache as this may result in deadlock. The most common case is a CacheFactory call from a custom CacheStore implementation.

2013-10-01 20:28:26.932/45.428 Oracle Coherence GE 3.7.1.6 <D7> (thread=pool-1-thread-1, member=1): Stack trace:

at com.tangosol.coherence.component.util.SafeService.checkClientThread(SafeService.CDB:38)

at com.tangosol.coherence.component.util.safeService.SafeCacheService.ensureCache(SafeCacheService.CDB:8)

at com.tangosol.net.DefaultConfigurableCacheFactory.ensureCache(DefaultConfigurableCacheFactory.java:920)

at com.tangosol.net.DefaultConfigurableCacheFactory.configureCache(DefaultConfigurableCacheFactory.java:1296)

at com.tangosol.net.DefaultConfigurableCacheFactory.ensureCache(DefaultConfigurableCacheFactory.java:297)

at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:204)

at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:181)

at com.barclays.tcv.cacheloader.GetAllAccountsForSysKeyCacheLoader$1.run(GetAllAccountsForSysKeyCacheLoader.java:156)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

at java.lang.Thread.run(Thread.java:662)

 

 

Here is my load() method in cache loader

public Object load(Object object) {

CustomerKey key = (CustomerKey)object;

//Query DB

//create localMap<K,V>

 

ExecutorService executorService = Executors.newCachedThreadPool(Executors.defaultThreadFactory());

   executorService.execute(new Runnable() { 

    public void run() {

     NamedCache customerCache = CacheFactory.getCache("TEST");

     customerCache.putAll(localMap);

    }

   });

 

    //return the value for the key, for which cache loader is triggered

  Customer customer = localMap.get(key);

  return customer;

}

 

 

Any ideas why am seeing this warning? Since am calling CacheFactory in new thread, I shouldn't be seeing this warning. Right?

 

Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points