From 0abb2be6ff6014ce7a6afa93085ef9bb73c6f5f2 Mon Sep 17 00:00:00 2001 From: Jerry Hu Date: Thu, 6 Jun 2024 18:00:54 +0800 Subject: [PATCH] [fix](fe) avoid setting the value of batch_size excessively high (#35941) ## Proposed changes Issue Number: close #xxx --- .../main/java/org/apache/doris/qe/SessionVariable.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java index 2b1b58d0baec84..a7f2a453d2e627 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java @@ -55,6 +55,7 @@ import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Field; +import java.security.InvalidParameterException; import java.security.SecureRandom; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; @@ -809,7 +810,7 @@ public class SessionVariable implements Serializable, Writable { public boolean haveQueryCache = false; // 4096 minus 16 + 16 bytes padding that in padding pod array - @VariableMgr.VarAttr(name = BATCH_SIZE, fuzzy = true) + @VariableMgr.VarAttr(name = BATCH_SIZE, fuzzy = true, checker = "checkBatchSize") public int batchSize = 4064; @VariableMgr.VarAttr(name = DISABLE_STREAMING_PREAGGREGATIONS, fuzzy = true) @@ -3860,6 +3861,13 @@ public void checkSqlDialect(String sqlDialect) { } } + public void checkBatchSize(String batchSize) { + Long batchSizeValue = Long.valueOf(batchSize); + if (batchSizeValue < 1 || batchSizeValue > 65535) { + throw new InvalidParameterException("batch_size should be between 1 and 65535)"); + } + } + public boolean isEnableInsertGroupCommit() { return Config.wait_internal_group_commit_finish || GroupCommitBlockSink.parseGroupCommit(groupCommit) == TGroupCommitMode.ASYNC_MODE