This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 406e861dab [imporvement](table property) support for alter table
property: skip wirte index , single compaction (#23475)
406e861dab is described below
commit 406e861dab2cb706fc9dd40fe00e3216284c91fa
Author: Chenyang Sun <[email protected]>
AuthorDate: Sat Aug 26 23:52:09 2023 +0800
[imporvement](table property) support for alter table property: skip wirte
index , single compaction (#23475)
---
be/src/agent/task_worker_pool.cpp | 27 +++++++++
.../main/java/org/apache/doris/alter/Alter.java | 14 ++---
.../org/apache/doris/alter/AlterOperations.java | 54 -----------------
.../apache/doris/alter/SchemaChangeHandler.java | 28 +++++++--
.../analysis/ModifyTablePropertiesClause.java | 68 ++++++++--------------
.../main/java/org/apache/doris/catalog/Env.java | 4 +-
.../org/apache/doris/catalog/TableProperty.java | 2 +
.../org/apache/doris/persist/OperationType.java | 6 +-
.../doris/task/UpdateTabletMetaInfoTask.java | 15 ++++-
gensrc/thrift/AgentService.thrift | 2 +
.../schema_change/test_alter_table_property.groovy | 51 ++++++++++++++++
11 files changed, 155 insertions(+), 116 deletions(-)
diff --git a/be/src/agent/task_worker_pool.cpp
b/be/src/agent/task_worker_pool.cpp
index b7a46ec7ba..fe29c2a188 100644
--- a/be/src/agent/task_worker_pool.cpp
+++ b/be/src/agent/task_worker_pool.cpp
@@ -503,6 +503,33 @@ void
TaskWorkerPool::_update_tablet_meta_worker_thread_callback() {
tablet->set_binlog_config(new_binlog_config);
need_to_save = true;
}
+ if (tablet_meta_info.__isset.enable_single_replica_compaction) {
+ std::shared_lock rlock(tablet->get_header_lock());
+ tablet->tablet_meta()
+ ->mutable_tablet_schema()
+ ->set_enable_single_replica_compaction(
+
tablet_meta_info.enable_single_replica_compaction);
+ for (auto& rowset_meta :
tablet->tablet_meta()->all_mutable_rs_metas()) {
+
rowset_meta->tablet_schema()->set_enable_single_replica_compaction(
+ tablet_meta_info.enable_single_replica_compaction);
+ }
+
tablet->tablet_schema_unlocked()->set_enable_single_replica_compaction(
+ tablet_meta_info.enable_single_replica_compaction);
+ need_to_save = true;
+ }
+
+ if (tablet_meta_info.__isset.skip_write_index_on_load) {
+ std::shared_lock rlock(tablet->get_header_lock());
+
tablet->tablet_meta()->mutable_tablet_schema()->set_skip_write_index_on_load(
+ tablet_meta_info.skip_write_index_on_load);
+ for (auto& rowset_meta :
tablet->tablet_meta()->all_mutable_rs_metas()) {
+ rowset_meta->tablet_schema()->set_skip_write_index_on_load(
+ tablet_meta_info.skip_write_index_on_load);
+ }
+ tablet->tablet_schema_unlocked()->set_skip_write_index_on_load(
+ tablet_meta_info.skip_write_index_on_load);
+ need_to_save = true;
+ }
if (need_to_save) {
std::shared_lock rlock(tablet->get_header_lock());
tablet->save_meta();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
index 8a423e5894..34f8a0b991 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
@@ -211,14 +211,6 @@ public class Alter {
} else if (currentAlterOps.checkIsBeingSynced(alterClauses)) {
olapTable.setIsBeingSynced(currentAlterOps.isBeingSynced(alterClauses));
needProcessOutsideTableLock = true;
- } else if (currentAlterOps.checkCompactionPolicy(alterClauses)) {
- needProcessOutsideTableLock = true;
- } else if
(currentAlterOps.checkTimeSeriesCompactionGoalSizeMbytes(alterClauses)) {
- needProcessOutsideTableLock = true;
- } else if
(currentAlterOps.checkTimeSeriesCompactionFileCountThreshold(alterClauses)) {
- needProcessOutsideTableLock = true;
- } else if
(currentAlterOps.checkTimeSeriesCompactionTimeThresholdSeconds(alterClauses)) {
- needProcessOutsideTableLock = true;
} else if (currentAlterOps.checkBinlogConfigChange(alterClauses)) {
if (!Config.enable_feature_binlog) {
throw new DdlException("Binlog feature is not enabled");
@@ -528,7 +520,11 @@ public class Alter {
|| properties
.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_FILE_COUNT_THRESHOLD)
|| properties
-
.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS));
+
.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS)
+ || properties
+
.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION)
+ || properties
+
.containsKey(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD));
((SchemaChangeHandler)
schemaChangeHandler).updateTableProperties(db, tableName, properties);
} else {
throw new DdlException("Invalid alter operation: " +
alterClause.getOpType());
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java
index 62721fa37e..22104522ed 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java
@@ -93,60 +93,6 @@ public class AlterOperations {
||
clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_HISTORY_NUMS));
}
- public boolean checkCompactionPolicy(List<AlterClause> alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).anyMatch(clause ->
clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_COMPACTION_POLICY));
- }
-
- public String getCompactionPolicy(List<AlterClause> alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).map(c -> ((ModifyTablePropertiesClause)
c).compactionPolicy()).findFirst().orElse("");
- }
-
- public boolean checkTimeSeriesCompactionGoalSizeMbytes(List<AlterClause>
alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).anyMatch(clause -> clause.getProperties()
-
.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES));
- }
-
- public long getTimeSeriesCompactionGoalSizeMbytes(List<AlterClause>
alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).map(c -> ((ModifyTablePropertiesClause) c)
- .timeSeriesCompactionGoalSizeMbytes()).findFirst().orElse((long) -1);
- }
-
- public boolean
checkTimeSeriesCompactionFileCountThreshold(List<AlterClause> alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).anyMatch(clause -> clause.getProperties()
-
.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_FILE_COUNT_THRESHOLD));
- }
-
- public long getTimeSeriesCompactionFileCountThreshold(List<AlterClause>
alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).map(c -> ((ModifyTablePropertiesClause) c)
- .timeSeriesCompactionFileCountThreshold()).findFirst().orElse((long)
-1);
- }
-
- public boolean
checkTimeSeriesCompactionTimeThresholdSeconds(List<AlterClause> alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).anyMatch(clause -> clause.getProperties()
-
.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS));
- }
-
- public long getTimeSeriesCompactionTimeThresholdSeconds(List<AlterClause>
alterClauses) {
- return alterClauses.stream().filter(clause ->
- clause instanceof ModifyTablePropertiesClause
- ).map(c -> ((ModifyTablePropertiesClause) c)
- .timeSeriesCompactionTimeThresholdSeconds()).findFirst().orElse((long)
-1);
- }
-
public boolean isBeingSynced(List<AlterClause> alterClauses) {
return alterClauses.stream().filter(clause ->
clause instanceof ModifyTablePropertiesClause
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
index 14946d18c0..5ee5f076b3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
@@ -2172,14 +2172,28 @@ public class SchemaChangeHandler extends AlterHandler {
}
if (isInMemory < 0 && storagePolicyId < 0 && compactionPolicy == null
&& timeSeriesCompactionConfig.isEmpty()
- &&
!properties.containsKey(PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED)) {
+ &&
!properties.containsKey(PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED)
+ &&
!properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION)
+ &&
!properties.containsKey(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD)) {
LOG.info("Properties already up-to-date");
return;
}
+ String singleCompaction =
properties.get(PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION);
+ int enableSingleCompaction = -1; // < 0 means don't update
+ if (singleCompaction != null) {
+ enableSingleCompaction = Boolean.parseBoolean(singleCompaction) ?
1 : 0;
+ }
+
+ String skipWriteIndexOnLoad =
properties.get(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD);
+ int skip = -1; // < 0 means don't update
+ if (skipWriteIndexOnLoad != null) {
+ skip = Boolean.parseBoolean(skipWriteIndexOnLoad) ? 1 : 0;
+ }
+
for (Partition partition : partitions) {
updatePartitionProperties(db, olapTable.getName(),
partition.getName(), storagePolicyId, isInMemory,
- null, compactionPolicy,
timeSeriesCompactionConfig);
+ null, compactionPolicy,
timeSeriesCompactionConfig, enableSingleCompaction, skip);
}
olapTable.writeLockOrDdlException();
@@ -2222,7 +2236,7 @@ public class SchemaChangeHandler extends AlterHandler {
for (String partitionName : partitionNames) {
try {
updatePartitionProperties(db, olapTable.getName(),
partitionName, storagePolicyId,
-
isInMemory, null, null, null);
+
isInMemory, null, null, null, -1, -1);
} catch (Exception e) {
String errMsg = "Failed to update partition[" + partitionName
+ "]'s 'in_memory' property. "
+ "The reason is [" + e.getMessage() + "]";
@@ -2237,7 +2251,8 @@ public class SchemaChangeHandler extends AlterHandler {
*/
public void updatePartitionProperties(Database db, String tableName,
String partitionName, long storagePolicyId,
int isInMemory, BinlogConfig
binlogConfig, String compactionPolicy,
- Map<String, Long>
timeSeriesCompactionConfig) throws UserException {
+ Map<String, Long>
timeSeriesCompactionConfig,
+ int enableSingleCompaction, int
skipWriteIndexOnLoad) throws UserException {
// be id -> <tablet id,schemaHash>
Map<Long, Set<Pair<Long, Integer>>> beIdToTabletIdWithHash =
Maps.newHashMap();
OlapTable olapTable = (OlapTable)
db.getTableOrMetaException(tableName, Table.TableType.OLAP);
@@ -2269,7 +2284,8 @@ public class SchemaChangeHandler extends AlterHandler {
for (Map.Entry<Long, Set<Pair<Long, Integer>>> kv :
beIdToTabletIdWithHash.entrySet()) {
countDownLatch.addMark(kv.getKey(), kv.getValue());
UpdateTabletMetaInfoTask task = new
UpdateTabletMetaInfoTask(kv.getKey(), kv.getValue(), isInMemory,
- storagePolicyId, binlogConfig, countDownLatch,
compactionPolicy, timeSeriesCompactionConfig);
+ storagePolicyId, binlogConfig,
countDownLatch, compactionPolicy,
+ timeSeriesCompactionConfig,
enableSingleCompaction, skipWriteIndexOnLoad);
batchTask.addTask(task);
}
if (!FeConstants.runningUnitTest) {
@@ -2914,7 +2930,7 @@ public class SchemaChangeHandler extends AlterHandler {
for (Partition partition : partitions) {
updatePartitionProperties(db, olapTable.getName(),
partition.getName(), -1, -1,
- newBinlogConfig, null, null);
+ newBinlogConfig, null, null,
-1, -1);
}
olapTable.writeLockOrDdlException();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
index 1ef31b3734..0925154439 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
@@ -54,46 +54,6 @@ public class ModifyTablePropertiesClause extends
AlterTableClause {
return isBeingSynced;
}
- private String compactionPolicy;
-
- private long timeSeriesCompactionGoalSizeMbytes;
-
- private long timeSeriesCompactionFileCountThreshold;
-
- private long timeSeriesCompactionTimeThresholdSeconds;
-
- public void setCompactionPolicy(String compactionPolicy) {
- this.compactionPolicy = compactionPolicy;
- }
-
- public String compactionPolicy() {
- return compactionPolicy;
- }
-
- public void setTimeSeriesCompactionGoalSizeMbytes(long
timeSeriesCompactionGoalSizeMbytes) {
- this.timeSeriesCompactionGoalSizeMbytes =
timeSeriesCompactionGoalSizeMbytes;
- }
-
- public long timeSeriesCompactionGoalSizeMbytes() {
- return timeSeriesCompactionGoalSizeMbytes;
- }
-
- public void setTimeSeriesCompactionFileCountThreshold(long
timeSeriesCompactionFileCountThreshold) {
- this.timeSeriesCompactionFileCountThreshold =
timeSeriesCompactionFileCountThreshold;
- }
-
- public Long timeSeriesCompactionFileCountThreshold() {
- return timeSeriesCompactionFileCountThreshold;
- }
-
- public void setTimeSeriesCompactionTimeThresholdSeconds(long
timeSeriesCompactionTimeThresholdSeconds) {
- this.timeSeriesCompactionTimeThresholdSeconds =
timeSeriesCompactionTimeThresholdSeconds;
- }
-
- public Long timeSeriesCompactionTimeThresholdSeconds() {
- return timeSeriesCompactionTimeThresholdSeconds;
- }
-
public ModifyTablePropertiesClause(Map<String, String> properties) {
super(AlterOpType.MODIFY_TABLE_PROPERTY);
this.properties = properties;
@@ -192,7 +152,7 @@ public class ModifyTablePropertiesClause extends
AlterTableClause {
+ " or " +
PropertyAnalyzer.SIZE_BASED_COMPACTION_POLICY);
}
this.needTableStable = false;
- setCompactionPolicy(compactionPolicy);
+ this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
} else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES))
{
long goalSizeMbytes;
String goalSizeMbytesStr = properties
@@ -208,7 +168,7 @@ public class ModifyTablePropertiesClause extends
AlterTableClause {
+ goalSizeMbytesStr);
}
this.needTableStable = false;
- setTimeSeriesCompactionGoalSizeMbytes(goalSizeMbytes);
+ this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
} else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_FILE_COUNT_THRESHOLD))
{
long fileCountThreshold;
String fileCountThresholdStr = properties
@@ -224,7 +184,7 @@ public class ModifyTablePropertiesClause extends
AlterTableClause {
+ fileCountThresholdStr);
}
this.needTableStable = false;
- setTimeSeriesCompactionFileCountThreshold(fileCountThreshold);
+ this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
} else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS))
{
long timeThresholdSeconds;
String timeThresholdSecondsStr = properties
@@ -240,7 +200,27 @@ public class ModifyTablePropertiesClause extends
AlterTableClause {
+ timeThresholdSecondsStr);
}
this.needTableStable = false;
- setTimeSeriesCompactionTimeThresholdSeconds(timeThresholdSeconds);
+ this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
+ } else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD)) {
+ if
(!properties.get(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD).equalsIgnoreCase("true")
+ && !properties.get(PropertyAnalyzer
+
.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD).equalsIgnoreCase("false")) {
+ throw new AnalysisException(
+ "Property "
+ + PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD + "
should be set to true or false");
+ }
+ this.needTableStable = false;
+ this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
+ } else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION))
{
+ if
(!properties.get(PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION).equalsIgnoreCase("true")
+ && !properties.get(PropertyAnalyzer
+
.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION).equalsIgnoreCase("false")) {
+ throw new AnalysisException(
+ "Property "
+ +
PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION + " should be set
to true or false");
+ }
+ this.needTableStable = false;
+ this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
} else {
throw new AnalysisException("Unknown table property: " +
properties.keySet());
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index a1fd73a140..368f8a506a 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -4508,7 +4508,9 @@ public class Env {
.buildCompactionPolicy()
.buildTimeSeriesCompactionGoalSizeMbytes()
.buildTimeSeriesCompactionFileCountThreshold()
- .buildTimeSeriesCompactionTimeThresholdSeconds();
+ .buildTimeSeriesCompactionTimeThresholdSeconds()
+ .buildSkipWriteIndexOnLoad()
+ .buildEnableSingleReplicaCompaction();
// need to update partition info meta
for (Partition partition : table.getPartitions()) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
index a264332753..b0ae5c469e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
@@ -128,6 +128,8 @@ public class TableProperty implements Writable {
buildTimeSeriesCompactionGoalSizeMbytes();
buildTimeSeriesCompactionFileCountThreshold();
buildTimeSeriesCompactionTimeThresholdSeconds();
+ buildSkipWriteIndexOnLoad();
+ buildEnableSingleReplicaCompaction();
break;
default:
break;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java
b/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java
index 451a3eb7aa..8b653478a3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java
@@ -215,7 +215,11 @@ public class OperationType {
// set table replication_num config 266
public static final short OP_MODIFY_REPLICATION_NUM = 266;
- // set table in memory
+ // set table in memory (confusion)
+ // The actual opcode now represents
+ // modify table properties: inMemory, StoragePolicy, IsBeingSynced,
CompactionPolicy,
+ // TimeSeriesCompactionFileCountThreshold,
SeriesCompactionTimeThresholdSeconds,
+ // SkipWriteIndexOnLoad, EnableSingleReplicaCompaction.
public static final short OP_MODIFY_IN_MEMORY = 267;
// set table default distribution bucket num
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/task/UpdateTabletMetaInfoTask.java
b/fe/fe-core/src/main/java/org/apache/doris/task/UpdateTabletMetaInfoTask.java
index 7b368cbf7c..8f67aa81b5 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/task/UpdateTabletMetaInfoTask.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/task/UpdateTabletMetaInfoTask.java
@@ -50,6 +50,9 @@ public class UpdateTabletMetaInfoTask extends AgentTask {
private Map<String, Long> timeSeriesCompactionConfig = null; // null means
not to update compaction policy config
// For ReportHandler
private List<TTabletMetaInfo> tabletMetaInfos;
+ // < 0 means not to update property, > 0 means true, == 0 means false
+ private int enableSingleReplicaCompaction = -1;
+ private int skipWriteIndexOnLoad = -1;
public UpdateTabletMetaInfoTask(long backendId, Set<Pair<Long, Integer>>
tableIdWithSchemaHash) {
super(null, backendId, TTaskType.UPDATE_TABLET_META_INFO,
@@ -82,10 +85,14 @@ public class UpdateTabletMetaInfoTask extends AgentTask {
BinlogConfig binlogConfig,
MarkedCountDownLatch<Long, Set<Pair<Long,
Integer>>> latch,
String compactionPolicy,
- Map<String, Long>
timeSeriesCompactionConfig) {
+ Map<String, Long>
timeSeriesCompactionConfig,
+ int enableSingleReplicaCompaction,
+ int skipWriteIndexOnLoad) {
this(backendId, tableIdWithSchemaHash, inMemory, storagePolicyId,
binlogConfig, latch);
this.compactionPolicy = compactionPolicy;
this.timeSeriesCompactionConfig = timeSeriesCompactionConfig;
+ this.enableSingleReplicaCompaction = enableSingleReplicaCompaction;
+ this.skipWriteIndexOnLoad = skipWriteIndexOnLoad;
}
public void countDownLatch(long backendId, Set<Pair<Long, Integer>>
tablets) {
@@ -146,6 +153,12 @@ public class UpdateTabletMetaInfoTask extends AgentTask {
.get(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS));
}
}
+ if (enableSingleReplicaCompaction >= 0) {
+
metaInfo.setEnableSingleReplicaCompaction(enableSingleReplicaCompaction > 0);
+ }
+ if (skipWriteIndexOnLoad >= 0) {
+ metaInfo.setSkipWriteIndexOnLoad(skipWriteIndexOnLoad > 0);
+ }
updateTabletMetaInfoReq.addToTabletMetaInfos(metaInfo);
}
} else {
diff --git a/gensrc/thrift/AgentService.thrift
b/gensrc/thrift/AgentService.thrift
index 18a473e2d4..ec766106c3 100644
--- a/gensrc/thrift/AgentService.thrift
+++ b/gensrc/thrift/AgentService.thrift
@@ -412,6 +412,8 @@ struct TTabletMetaInfo {
11: optional i64 time_series_compaction_goal_size_mbytes
12: optional i64 time_series_compaction_file_count_threshold
13: optional i64 time_series_compaction_time_threshold_seconds
+ 14: optional bool enable_single_replica_compaction
+ 15: optional bool skip_write_index_on_load
}
struct TUpdateTabletMetaInfoReq {
diff --git
a/regression-test/suites/schema_change/test_alter_table_property.groovy
b/regression-test/suites/schema_change/test_alter_table_property.groovy
new file mode 100644
index 0000000000..6442b9c00e
--- /dev/null
+++ b/regression-test/suites/schema_change/test_alter_table_property.groovy
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+suite("test_alter_table_property") {
+ def tableName = "test_table"
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+
+ sql """
+ CREATE TABLE ${tableName} (
+ `c_custkey` int(11) NOT NULL COMMENT "",
+ `c_name` varchar(26) NOT NULL COMMENT "",
+ `c_address` varchar(41) NOT NULL COMMENT "",
+ `c_city` varchar(11) NOT NULL COMMENT ""
+ )
+ DUPLICATE KEY (`c_custkey`)
+ DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ );
+ """
+ sql """sync"""
+
+ def showResult1 = sql """show create table ${tableName}"""
+ logger.info("${showResult1}")
+
assertTrue(showResult1.toString().containsIgnoreCase('"enable_single_replica_compaction"
= "false"'))
+
+ sql """
+ alter table ${tableName} set ("enable_single_replica_compaction" =
"true")
+ """
+ sql """sync"""
+
+ def showResult2 = sql """show create table ${tableName}"""
+ logger.info("${showResult2}")
+
assertTrue(showResult2.toString().containsIgnoreCase('"enable_single_replica_compaction"
= "true"'))
+
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+ sql """sync"""
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]