apurtell commented on code in PR #5239:
URL: https://github.com/apache/hbase/pull/5239#discussion_r1198368591


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java:
##########
@@ -592,10 +593,27 @@ public int evictBlocksByHfileName(String hfileName) {
    * @return the heap size of evicted block
    */
   protected long evictBlock(LruCachedBlock block, boolean 
evictedByEvictionProcess) {
-    LruCachedBlock previous = map.remove(block.getCacheKey());
-    if (previous == null) {
+    // We need something effectively final for the lambda.
+    final AtomicBoolean evicted = new AtomicBoolean(false);
+    map.computeIfPresent(block.getCacheKey(), (k, v) -> {
+      // Run the victim handler before we remove the mapping in the L1 map. It 
must complete
+      // quickly because other removal or insertion operations can be blocked 
in the meantime.
+      if (evictedByEvictionProcess && victimHandler != null) {
+        victimHandler.cacheBlock(k, v.getBuffer());
+      }

Review Comment:
   The language I chose should be ambiguous enough to cover the distinction. I 
didn't want to really get into it. Let me know if it needs improving.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to