Skip to content

Commit

Permalink
[feature](replica) support force set replicate allocation for olap ta…
Browse files Browse the repository at this point in the history
…bles (apache#32916) (apache#33340)

Add a config to force set replication allocation for all OLAP tables and partitions.
  • Loading branch information
cambyzju authored Apr 8, 2024
1 parent bf2d528 commit af950f7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fe/fe-common/src/main/java/org/apache/doris/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,16 @@ public class Config extends ConfigBase {
+ "This config is recommended to be used only in the test environment"})
public static int force_olap_table_replication_num = 0;

@ConfField(mutable = true, masterOnly = true, description = {
"用于强制设定内表的副本分布,如果该参数不为空,则用户在建表或者创建分区时指定的副本数及副本标签将被忽略,而使用本参数设置的值。"
+ "该参数影响包括创建分区、修改表属性、动态分区等操作。该参数建议仅用于测试环境",
"Used to force set the replica allocation of the internal table. If the config is not empty, "
+ "the replication_num and replication_allocation specified by the user when creating the table "
+ "or partitions will be ignored, and the value set by this parameter will be used."
+ "This config effect the operations including create tables, create partitions and create "
+ "dynamic partitions. This config is recommended to be used only in the test environment"})
public static String force_olap_table_replication_allocation = "";

@ConfField
public static long statistics_sql_mem_limit_in_bytes = 2L * 1024 * 1024 * 1024;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,31 @@ public static ReplicaAllocation analyzeReplicaAllocationWithoutCheck(Map<String,

public static ReplicaAllocation analyzeReplicaAllocation(Map<String, String> properties, String prefix)
throws AnalysisException {
if (!Config.force_olap_table_replication_allocation.isEmpty()) {
properties = forceRewriteReplicaAllocation(properties, prefix);
}
return analyzeReplicaAllocationImpl(properties, prefix, true);
}

public static Map<String, String> forceRewriteReplicaAllocation(Map<String, String> properties,
String prefix) {
if (properties == null) {
properties = Maps.newHashMap();
}
String propNumKey = Strings.isNullOrEmpty(prefix) ? PROPERTIES_REPLICATION_NUM
: prefix + "." + PROPERTIES_REPLICATION_NUM;
if (properties.containsKey(propNumKey)) {
properties.remove(propNumKey);
}
String propTagKey = Strings.isNullOrEmpty(prefix) ? PROPERTIES_REPLICATION_ALLOCATION
: prefix + "." + PROPERTIES_REPLICATION_ALLOCATION;
if (properties.containsKey(propTagKey)) {
properties.remove(propTagKey);
}
properties.put(propTagKey, Config.force_olap_table_replication_allocation);
return properties;
}

// There are 2 kinds of replication property:
// 1. "replication_num" = "3"
// 2. "replication_allocation" = "tag.location.zone1: 2, tag.location.zone2: 1"
Expand Down

0 comments on commit af950f7

Please sign in to comment.