You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/07/16 20:50:20 UTC

[GitHub] [hbase] apurtell commented on a change in pull request #3495: HBASE-24984 WAL corruption due to early DBBs re-use when Durability.A…

apurtell commented on a change in pull request #3495:
URL: https://github.com/apache/hbase/pull/3495#discussion_r671515927



##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java
##########
@@ -97,11 +97,13 @@
   private long exceptionSize = 0;
   private final boolean retryImmediatelySupported;
 
-  // This is a dirty hack to address HBASE-22539. The lowest bit is for normal rpc cleanup, and the
-  // second bit is for WAL reference. We can only call release if both of them are zero. The reason
-  // why we can not use a general reference counting is that, we may call cleanup multiple times in
-  // the current implementation. We should fix this in the future.
-  private final AtomicInteger reference = new AtomicInteger(0b01);
+  // This is a dirty hack to address HBASE-22539. The highest bit is for rpc ref and cleanup, and
+  // the rest of the bits are for WAL reference count. We can only call release if all of them are
+  // zero. The reason why we can not use a general reference counting is that, we may call cleanup
+  // multiple times in the current implementation. We should fix this in the future.
+  // The refCount here will start as 0x80000000 and increment with every WAL reference and decrement
+  // from WAL side on release
+  private final AtomicInteger reference = new AtomicInteger(0x80000000);

Review comment:
       We can represent this as an atomic boolean and atomic integer together, right? We are either checking or adjusting the high order bit atomically or adjusting the refcount atomically, we aren't doing both together. There isn't a case where the high order bit is updated *and* the refcount is changed and both must be applied as a single atomic operation. 
   
   The code will be much more understandable and maintainable with a well-named atomic boolean field and the result is no longer a dirty hack.




-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org