From df26fb2de445c4c1fecbc39c02a2f35a3cfb93f2 Mon Sep 17 00:00:00 2001 From: Chenyang Sun Date: Thu, 10 Aug 2023 17:12:42 +0800 Subject: [PATCH] [fix][alter table property] fix alter table property failed (#22791) --- .../org/apache/doris/alter/SchemaChangeHandler.java | 11 ++++++----- .../java/org/apache/doris/catalog/TableProperty.java | 4 ++++ .../test_table_level_compaction_policy.groovy | 11 +++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) 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 df7fdc81c0..61865df13a 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 @@ -2166,16 +2166,17 @@ public class SchemaChangeHandler extends AlterHandler { .get(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS))); } + if (isInMemory < 0 && storagePolicyId < 0 && compactionPolicy == null && timeSeriesCompactionConfig.isEmpty() + && !properties.containsKey(PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED)) { + LOG.info("Properties already up-to-date"); + return; + } + for (Partition partition : partitions) { updatePartitionProperties(db, olapTable.getName(), partition.getName(), storagePolicyId, isInMemory, null, compactionPolicy, timeSeriesCompactionConfig); } - if (isInMemory < 0 && storagePolicyId < 0 && compactionPolicy == null && timeSeriesCompactionConfig.isEmpty()) { - LOG.info("Properties already up-to-date"); - return; - } - olapTable.writeLockOrDdlException(); try { Env.getCurrentEnv().modifyTableProperties(db, olapTable, properties); 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 c8b6cdb53e..a264332753 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 @@ -124,6 +124,10 @@ public class TableProperty implements Writable { buildInMemory(); buildStoragePolicy(); buildIsBeingSynced(); + buildCompactionPolicy(); + buildTimeSeriesCompactionGoalSizeMbytes(); + buildTimeSeriesCompactionFileCountThreshold(); + buildTimeSeriesCompactionTimeThresholdSeconds(); break; default: break; diff --git a/regression-test/suites/compaction/test_table_level_compaction_policy.groovy b/regression-test/suites/compaction/test_table_level_compaction_policy.groovy index f2df7fe9bb..5bb33eebf2 100644 --- a/regression-test/suites/compaction/test_table_level_compaction_policy.groovy +++ b/regression-test/suites/compaction/test_table_level_compaction_policy.groovy @@ -38,6 +38,8 @@ suite("test_table_level_compaction_policy") { "time_series_compaction_time_threshold_seconds" = "86400" ); """ + sql """sync""" + def showResult1 = sql """show create table ${tableName}""" logger.info("${showResult1}") assertTrue(showResult1.toString().containsIgnoreCase('"compaction_policy" = "time_series"')) @@ -48,6 +50,7 @@ suite("test_table_level_compaction_policy") { sql """ alter table ${tableName} set ("time_series_compaction_goal_size_mbytes" = "1024") """ + sql """sync""" def showResult2 = sql """show create table ${tableName}""" logger.info("${showResult2}") @@ -56,6 +59,7 @@ suite("test_table_level_compaction_policy") { sql """ alter table ${tableName} set ("time_series_compaction_file_count_threshold" = "6000") """ + sql """sync""" def showResult3 = sql """show create table ${tableName}""" logger.info("${showResult3}") @@ -64,12 +68,14 @@ suite("test_table_level_compaction_policy") { sql """ alter table ${tableName} set ("time_series_compaction_time_threshold_seconds" = "3000") """ + sql """sync""" def showResult4 = sql """show create table ${tableName}""" logger.info("${showResult4}") assertTrue(showResult4.toString().containsIgnoreCase('"time_series_compaction_time_threshold_seconds" = "3000"')) sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """sync""" sql """ CREATE TABLE ${tableName} ( @@ -84,11 +90,14 @@ suite("test_table_level_compaction_policy") { "replication_num" = "1" ); """ + sql """sync""" + def showResult5 = sql """show create table ${tableName}""" logger.info("${showResult5}") assertFalse(showResult5.toString().containsIgnoreCase('"compaction_policy"')) sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """sync""" test { sql """ @@ -197,6 +206,7 @@ suite("test_table_level_compaction_policy") { "replication_num" = "1" ); """ + sql """sync""" sql """ alter table ${tableName} set ("compaction_policy" = "ok") @@ -204,4 +214,5 @@ suite("test_table_level_compaction_policy") { exception "Table compaction policy only support for time_series or size_based" } sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """sync""" }