Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/337#discussion_r88889114
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/cache/CacheProvider.java ---
    @@ -84,14 +84,13 @@ public static CacheProvider getInstance() {
         //check if cache is null for given cache type, if null create one
         if (!dictionaryCacheAlreadyExists(cacheType)) {
           synchronized (lock) {
    -        if (!dictionaryCacheAlreadyExists(cacheType)) {
    -          if (null == cacheTypeToLRUCacheMap.get(cacheType)) {
    -            createLRULevelCacheInstance(cacheType);
    -          }
    -          createDictionaryCacheForGivenType(cacheType, carbonStorePath);
    +        if (null == cacheTypeToLRUCacheMap.get(cacheType)) {
    +          createLRULevelCacheInstance(cacheType);
             }
    +        createDictionaryCacheForGivenType(cacheType, carbonStorePath);
    --- End diff --
    
    @PallaviSingh1992 ....dictionaryCacheAlreadyExists will check if for a 
given cache type (Forward/Reverse), the object has already been created. Now 
this check is before and inside synchronized block to handle concurrent access 
(double locking mechanism). If this check is removed inside the synchronized 
block then it can happen that in concurrent scenarios, multiple threads end up 
in creating multiple objects for the same cache type and the object in the map 
keeps getting overridden. 
    Therefore I think that this double check is required. Please correct me if 
I am wrong.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to