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

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


The following commit(s) were added to refs/heads/master by this push:
     new a94781f3f93 [chore](cloud) Run GC if not enough memory when checkpoint 
(#35331)
a94781f3f93 is described below

commit a94781f3f933dccfda07c372321d2546136c6d5a
Author: walter <[email protected]>
AuthorDate: Tue May 28 16:25:45 2024 +0800

    [chore](cloud) Run GC if not enough memory when checkpoint (#35331)
---
 .../src/main/java/org/apache/doris/common/Config.java |  8 ++++++++
 .../main/java/org/apache/doris/master/Checkpoint.java | 19 +++++++++++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java 
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index 53bdc04a8d7..3853e5f896c 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -2618,6 +2618,13 @@ public class Config extends ConfigBase {
     })
     public static boolean enable_advance_next_id = false;
 
+    // The count threshold to do manual GC when doing checkpoint but not 
enough memory.
+    // Set zero to disable it.
+    @ConfField(description = {
+            "如果 checkpoint 连续多次因内存不足而无法进行时,先尝试手动触发 GC",
+            "The threshold to do manual GC when doing checkpoint but not 
enough memory"})
+    public static int checkpoint_manual_gc_threshold = 0;
+
     
//==========================================================================
     //                    begin of cloud config
     
//==========================================================================
@@ -2841,6 +2848,7 @@ public class Config extends ConfigBase {
     @ConfField(description = {"存算分离模式下streamload导入使用的转发策略, 
可选值为public-private或者空",
             "streamload route policy in cloud mode, availale options are 
public-private and empty string"})
     public static String streamload_redirect_policy = "";
+
     
//==========================================================================
     //                      end of cloud config
     
//==========================================================================
diff --git a/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java 
b/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java
index 33aa9e7bd15..27dc6aa7b87 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java
@@ -58,6 +58,7 @@ public class Checkpoint extends MasterDaemon {
     private Env env;
     private String imageDir;
     private EditLog editLog;
+    private int memoryNotEnoughCount = 0;
 
     public Checkpoint(EditLog editLog) {
         super("leaderCheckpointer", FeConstants.checkpoint_interval_second * 
1000L);
@@ -323,13 +324,23 @@ public class Checkpoint extends MasterDaemon {
         long memUsedPercent = getMemoryUsedPercent();
         LOG.info("get jvm memory used percent: {} %", memUsedPercent);
 
-        if (memUsedPercent > Config.metadata_checkpoint_memory_threshold && 
!Config.force_do_metadata_checkpoint) {
-            LOG.warn("the memory used percent {} exceed the checkpoint memory 
threshold: {}",
-                    memUsedPercent, 
Config.metadata_checkpoint_memory_threshold);
+        if (memUsedPercent <= Config.metadata_checkpoint_memory_threshold || 
Config.force_do_metadata_checkpoint) {
+            memoryNotEnoughCount = 0;
+            return true;
+        }
+
+        LOG.warn("the memory used percent {} exceed the checkpoint memory 
threshold: {}, exceeded count: {}",
+                memUsedPercent, Config.metadata_checkpoint_memory_threshold, 
memoryNotEnoughCount);
+
+        memoryNotEnoughCount += 1;
+        if (memoryNotEnoughCount != Config.checkpoint_manual_gc_threshold) {
             return false;
         }
 
-        return true;
+        LOG.warn("the not enough memory count has reached the manual gc 
threshold {}",
+                Config.checkpoint_manual_gc_threshold);
+        System.gc();
+        return checkMemoryEnoughToDoCheckpoint();
     }
 
     /*


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to