OneSizeFitsQuorum commented on code in PR #12431:
URL: https://github.com/apache/iotdb/pull/12431#discussion_r1590800057


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java:
##########
@@ -3456,12 +3460,37 @@ public void markDeleted() {
     writeLock("markDeleted");
     try {
       deleted = true;
+      releaseDirectBufferMemory();
       deletedCondition.signalAll();
     } finally {
       writeUnlock();
     }
   }
 
+  private void acquireDirectBufferMemory() throws DataRegionException {
+    long acquireDirectBufferMemCost = 0;
+    if 
(config.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.IOT_CONSENSUS))
 {
+      acquireDirectBufferMemCost = config.getWalBufferSize();
+    } else if (config
+        .getDataRegionConsensusProtocolClass()
+        .equals(ConsensusFactory.RATIS_CONSENSUS)) {
+      acquireDirectBufferMemCost = 
config.getDataRatisConsensusLogAppenderBufferSizeMax();
+    }
+    if 
(!SystemInfo.getInstance().addDirectBufferMemoryCost(acquireDirectBufferMemCost))
 {
+      throw new DataRegionException(
+          "Total allocated memory for direct buffer will be "
+              + (SystemInfo.getInstance().getDirectBufferMemoryCost() + 
acquireDirectBufferMemCost)
+              + ", which is greater than limit mem cost: "
+              + 
SystemInfo.getInstance().getTotalDirectBufferMemorySizeLimit());
+    }
+    this.directBufferMemoryCost = acquireDirectBufferMemCost;
+  }
+
+  private void releaseDirectBufferMemory() {
+    
SystemInfo.getInstance().decreaseDirectBufferMemoryCost(directBufferMemoryCost);
+    this.directBufferMemoryCost = 0;

Review Comment:
   add some comments for repeat deletion



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java:
##########
@@ -419,6 +419,24 @@ public void loadProperties(Properties properties) throws 
BadNodeUrlException, IO
                 "max_waiting_time_when_insert_blocked",
                 Integer.toString(conf.getMaxWaitingTimeWhenInsertBlocked()))));
 
+    String offHeapMemoryStr = System.getProperty("OFF_HEAP_MEMORY");
+    if (offHeapMemoryStr != null) {
+      offHeapMemoryStr = offHeapMemoryStr.toLowerCase();

Review Comment:
   abstract a function



##########
iotdb-core/datanode/src/assembly/resources/sbin/start-datanode.sh:
##########
@@ -163,6 +163,7 @@ launch_service()
        iotdb_parms="$iotdb_parms -DTSFILE_CONF=${IOTDB_CONF}"
        iotdb_parms="$iotdb_parms -Dname=iotdb\.IoTDB"
        iotdb_parms="$iotdb_parms -DIOTDB_LOG_DIR=${IOTDB_LOG_DIR}"
+       iotdb_parms="$iotdb_parms -DOFF_HEAP_MEMORY=${OFF_HEAP_MEMORY}"

Review Comment:
   1. lack windows
   2. describe the compatibility in pr



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/SystemInfo.java:
##########
@@ -352,6 +378,12 @@ public long getMemorySizeForCompaction() {
   }
 
   public void allocateWriteMemory() {
+    totalDirectBufferMemorySizeLimit =
+        config.getMaxOffHeapMemoryBytes() == 0
+            ? Long.MAX_VALUE

Review Comment:
   add some comments for this default value



-- 
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: reviews-unsubscr...@iotdb.apache.org

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

Reply via email to