YutSean commented on a change in pull request #4026:
URL: https://github.com/apache/hbase/pull/4026#discussion_r788276206



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
##########
@@ -1522,9 +1523,15 @@ public BucketEntry writeToCache(final IOEngine ioEngine, 
final BucketAllocator a
           // If an instance of HFileBlock, save on some allocations.
           HFileBlock block = (HFileBlock) data;
           ByteBuff sliceBuf = block.getBufferReadOnly();
-          ByteBuffer metadata = block.getMetaData();
+          block.getMetaData(metaBuff);
           ioEngine.write(sliceBuf, offset);
-          ioEngine.write(metadata, offset + len - metadata.limit());
+          ioEngine.write(metaBuff, offset + len - metaBuff.limit());
+          // Reset the position for reuse.
+          // The data in metaBuff should be guaranteed that has been 
transferred to the ioEngine
+          // safely. Otherwise, this reuse is problematic. Fortunately, the 
data is already
+          // transferred with our current IOEngines. Should take care, when we 
have new types of
+          // IOEngine in the future.
+          metaBuff.clear();

Review comment:
       Have made the metaBuff cleared before invoking of #writeToCache. I think 
this can keep the metaBuff clean every time we writeToCache even if the 
IOEngine had exception and failed the last block write. 




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