wchevreuil commented on code in PR #8469:
URL: https://github.com/apache/hbase/pull/8469#discussion_r3660018931


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java:
##########
@@ -1350,13 +1384,20 @@ public void run() {
    */
   protected void putIntoBackingMap(BlockCacheKey key, BucketEntry bucketEntry) 
{
     BucketEntry previousEntry = backingMap.put(key, bucketEntry);
-    blocksByHFile.add(key);
     updateRegionCachedSize(key, bucketEntry.getLength());
     if (previousEntry != null && previousEntry != bucketEntry) {
       previousEntry.withWriteLock(offsetLock, () -> {
         blockEvicted(key, previousEntry, false, false);
         return null;
       });
+      bucketEntry.withWriteLock(offsetLock, () -> {
+        if (backingMap.get(key) == bucketEntry) {
+          blocksByHFile.add(key);
+        }
+        return null;
+      });
+    } else {
+      blocksByHFile.add(key);

Review Comment:
   Why do we need this lock when previousEntry != null, and why we don't when 
it's null?



-- 
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