openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Drewz <andrew....@elasticpath.com>
Subject DataCacheStoreManager locking
Date Thu, 08 Oct 2009 18:48:37 GMT

Hi guys,

I'm trying to understand the rationale for some of the locking occurring in
DataCacheStoreManager. Under certain circumstances of high load, we have a
lot of waiting threads on cache.writeLock(). This may be normal, but I want
to understand the blocks of code that look similar to:

        // make sure that we're not trying to cache an old version
        cache.writeLock();
        try {
            data = cache.get(sm.getObjectId());
            if (data != null && compareVersion(sm, sm.getVersion(),
                data.getVersion()) == VERSION_EARLIER)
                return true;

            // cache newly loaded info. It is safe to cache data frorm
            // initialize() because this method is only called upon
            // initial load of the data.
            if (data == null)
                data = newPCData(sm);
            data.store(sm);
            cache.put(data);
        } finally {
            cache.writeUnlock();
        }

What part of the underlying DataCache requires locking, and why isn't this
lock done closer to the cache.put? I see the CacheMap has it's own writeLock
mechanism, which I thought would make the writeLock cals on
ConcurrentDataCache redundant? Please correct me if that is not the case.

Thanks,

Drew
-- 
View this message in context: http://n2.nabble.com/DataCacheStoreManager-locking-tp3790050p3790050.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message