You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2019/02/27 20:50:27 UTC

[GitHub] mikewalch commented on a change in pull request #990: Avoid multiple threads loading same cache block

mikewalch commented on a change in pull request #990: Avoid multiple threads loading same cache block
URL: https://github.com/apache/accumulo/pull/990#discussion_r260936292
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
 ##########
 @@ -379,18 +381,35 @@ private BlockRead getBlock(String _lookup, BlockCache cache, BlockLoader loader)
           return new CachedBlockRead(cb, cb.getBuffer());
         }
 
+        loadLock = cache.getLoadLock(_lookup);
       }
-      /**
-       * grab the currBlock at this point the block is still in the data stream
-       *
-       */
-      _currBlock = loader.get();
 
-      /**
-       * If the block is bigger than the cache just return the stream
-       */
-      return cacheBlock(_lookup, cache, _currBlock, loader.getInfo());
+      try {
+        if (loadLock != null) {
+          loadLock.lock();
+
+          // check cache again after getting lock
+          CacheEntry cb = cache.getBlockNoStats(_lookup);
+
+          if (cb != null) {
+            return new CachedBlockRead(cb, cb.getBuffer());
+          }
+        }
 
+        /**
+         * grab the currBlock at this point the block is still in the data stream
+         *
+         */
+        _currBlock = loader.get();
 
 Review comment:
   what is the point of the `_` in `_currBlock`? is there some special meaning?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services