sidkhillon commented on code in PR #8611:
URL: https://github.com/apache/hbase/pull/8611#discussion_r4037235617


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SyncFutureCache.java:
##########
@@ -57,9 +61,15 @@ public SyncFutureCache(final Configuration conf) {
   }
 
   public SyncFuture getIfPresentOrNew() {
-    // Invalidate the entry if a mapping exists. We do not want it to be 
reused at the same time.
-    SyncFuture future = syncFutureCache.asMap().remove(Thread.currentThread());
-    return (future == null) ? new SyncFuture() : future;
+    // The cache is only an allocation optimisation; never let it fail a write.
+    try {
+      // Invalidate the entry if a mapping exists. We do not want it to be 
reused at the same time.
+      SyncFuture future = 
syncFutureCache.asMap().remove(Thread.currentThread());
+      return (future == null) ? new SyncFuture() : future;
+    } catch (RuntimeException e) {

Review Comment:
   There can be the same NPE from Guava's `LocalCache` write-queue
   
   ```java
   java.lang.NullPointerException: Cannot invoke 
"...ReferenceEntry.setNextInWriteQueue(...)" because "previous" is null
       at 
org.apache.hbase.thirdparty.com.google.common.cache.LocalCache.connectWriteOrder(LocalCache.java:1818)
       at 
org.apache.hbase.thirdparty.com.google.common.cache.LocalCache$WriteQueue.remove(LocalCache.java:3725)
       at 
org.apache.hbase.thirdparty.com.google.common.cache.LocalCache.remove(LocalCache.java:4273)
       at 
org.apache.hadoop.hbase.regionserver.wal.SyncFutureCache.getIfPresentOrNew(SyncFutureCache.java:61)
   ```
   
   I'm happy to reduce this to just a NPE catch if you'd like. I kept it broad 
so any exception falls back to a new SyncFuture()



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