ankitsinghal commented on code in PR #5371:
URL: https://github.com/apache/hbase/pull/5371#discussion_r1310496448


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java:
##########
@@ -1285,12 +1320,104 @@ void persistToFile() throws IOException {
       LOG.warn("Failed to commit cache persistent file. We might lose cached 
blocks if "
         + "RS crashes/restarts before we successfully checkpoint again.");
     }
+    LOG.debug("Saving current state of bucket cache index map took {}ms.",
+      EnvironmentEdgeManager.currentTime() - startTime);
+  }
+
+  private void recordTransaction(BlockCacheKey key, BucketEntry bucketEntry,
+    BucketCacheProtos.TransactionType type) {
+    if (persistencePath != null) {
+      File path = new File(persistencePath + "tx-" + System.nanoTime());
+      long startTime = EnvironmentEdgeManager.currentTime();
+      try (FileOutputStream fos = new FileOutputStream(path, false)) {
+        fos.write(ProtobufMagic.PB_MAGIC);
+        BucketProtoUtils.toPB(this, key, bucketEntry, 
type).writeDelimitedTo(fos);
+        txsCount.incrementAndGet();
+        fos.flush();
+      } catch (Exception e) {
+        LOG.error("Failed to record cache transaction {} for key {}. In the 
event of a crash, "
+          + "this key would require a re-cache.", type.name(), key, e);
+      }
+      LOG.debug("Cache transaction recording took {}ms",
+        EnvironmentEdgeManager.currentTime() - startTime);
+    }

Review Comment:
   we have this in the critical path of the reads, having it synchronous could 
delay the performance of the reads during both cases of eviction or addition 
blocks. This will also generate a large amount of files as we are creating new 
files for every transaction. Or we are doing this only in a very special case?



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