You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/04/26 14:50:48 UTC

[iotdb] branch master updated: [IOTDB-3014] [Rocksdb_based] fix OOM (#5677)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 787456ac3e [IOTDB-3014] [Rocksdb_based] fix OOM (#5677)
787456ac3e is described below

commit 787456ac3e03469e8d06099b9b03775333d4c373
Author: lisijia <44...@users.noreply.github.com>
AuthorDate: Tue Apr 26 22:50:42 2022 +0800

    [IOTDB-3014] [Rocksdb_based] fix OOM (#5677)
---
 .../resources/conf/schema-rocksdb.properties       | 24 ++++++++++++++--------
 .../schemaregion/rocksdb/RSchemaConfLoader.java    |  7 +++++--
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/server/src/assembly/resources/conf/schema-rocksdb.properties b/server/src/assembly/resources/conf/schema-rocksdb.properties
index d1c64e07dc..fafacf4afb 100644
--- a/server/src/assembly/resources/conf/schema-rocksdb.properties
+++ b/server/src/assembly/resources/conf/schema-rocksdb.properties
@@ -28,18 +28,26 @@
 ### Cache Configuration
 ####################
 # A proper cache size can speed up metadata query.You can configure the cache size as required.
+# By default, the block cache is calculated based on parameter 'write_read_schema_free_memory_proportion' in 'iotdb-engine.properties'.
+# Assuming 30GB of memory allocated to the schema, that will allocate 30GB to the following configuration items in proportion.
 
 # Datatype: long
-# LRU block cache size
-# Block cache is where RocksDB caches data in memory for reads.
-# The block cache stores uncompressed blocks.The default is 20 GB.
-# block_cache_size=21474836480
+# LRU block cache size. Block cache is where RocksDB caches data in memory for reads.
+# The block cache stores uncompressed blocks.
+# The default value is 2/3 of the schema memory configured for parameter
+# 'write_read_schema_free_memory_proportion' in the 'iotdb-engine.properties'.
+# For example, if the total configured memory size is 30GB and the schema ratio is 1/10,
+# the default value is 30GB * 1/10 * 2/3
+# block_cache_size=2147483648
 
 # Datatype: long
-# LRU block cache size
-# Block cache is where RocksDB caches data in memory for reads.
-# The block cache stores compressed blocks.The default is 10 GB.
-# block_cache_compressed_size=10737418240
+# LRU block cache size. Block cache is where RocksDB caches data in memory for reads.
+# The block cache stores compressed blocks.
+# The default value is 1/3 of the schema memory configured for parameter
+# 'write_read_schema_free_memory_proportion' in the 'iotdb-engine.properties'.
+# For example, if the total configured memory size is 30GB and the schema ratio is 1/10,
+# the default value is 30GB * 1/10 * 1/3
+# block_cache_compressed_size=1073741824
 
 ####################
 ### Professional Configuration
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaConfLoader.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaConfLoader.java
index e2be64186d..adb14caffa 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaConfLoader.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaConfLoader.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.db.metadata.schemaregion.rocksdb;
 
 import org.apache.iotdb.commons.conf.IoTDBConstant;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
 
 import org.rocksdb.util.SizeUnit;
 import org.slf4j.Logger;
@@ -44,8 +45,10 @@ public class RSchemaConfLoader {
   private long blockSize = 4 * SizeUnit.KB;
   private long writeBufferSize = 64 * SizeUnit.KB;
   private long maxTotalWalSize = 64 * SizeUnit.KB;
-  private long blockCache = 20L * 1024 * 1024 * 1024;
-  private long blockCacheCompressed = 10L * 1024 * 1024 * 1024;
+  private long blockCache =
+      IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForSchema() * 2 / 3;
+  private long blockCacheCompressed =
+      IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForSchema() / 3;
 
   private static final String ROCKSDB_CONFIG_FILE_NAME = "schema-rocksdb.properties";
   private static final Logger logger = LoggerFactory.getLogger(RSchemaConfLoader.class);