This is an automated email from the ASF dual-hosted git repository.
dataroaring 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 5d4be006a3c [fix](dynamic partition) fix dynamic partition thread met
uncatch exception #35778 (#35824)
5d4be006a3c is described below
commit 5d4be006a3c3005a7c93619c142099589d2cc389
Author: yujun <[email protected]>
AuthorDate: Wed Jun 5 08:53:44 2024 +0800
[fix](dynamic partition) fix dynamic partition thread met uncatch exception
#35778 (#35824)
cherry pick from #35778
---
.../apache/doris/catalog/ColocateGroupSchema.java | 5 +-
.../doris/clone/DynamicPartitionScheduler.java | 90 ++++++++++++++--------
.../java/org/apache/doris/common/ErrorCode.java | 4 +-
.../doris/common/util/DynamicPartitionUtil.java | 23 +++---
.../java/org/apache/doris/alter/AlterTest.java | 10 ++-
.../apache/doris/catalog/ColocateTableTest.java | 4 +-
.../doris/catalog/DynamicPartitionTableTest.java | 20 +++++
.../suites/delete_p0/test_delete.groovy | 10 +--
.../suites/index_p0/test_bitmap_index.groovy | 26 -------
.../test_dynamic_partition_failed.groovy | 74 ++++++++++++++++++
10 files changed, 181 insertions(+), 85 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java
index 5ec6a60c8dd..8f3d8c9af5a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java
@@ -85,12 +85,13 @@ public class ColocateGroupSchema implements Writable {
HashDistributionInfo info = (HashDistributionInfo)
distributionInfo;
// buckets num
if (info.getBucketNum() != bucketsNum) {
-
ErrorReport.reportDdlException(ErrorCode.ERR_COLOCATE_TABLE_MUST_HAS_SAME_BUCKET_NUM,
bucketsNum);
+
ErrorReport.reportDdlException(ErrorCode.ERR_COLOCATE_TABLE_MUST_HAS_SAME_BUCKET_NUM,
+ info.getBucketNum(), bucketsNum);
}
// distribution col size
if (info.getDistributionColumns().size() !=
distributionColTypes.size()) {
ErrorReport.reportDdlException(ErrorCode.ERR_COLOCATE_TABLE_MUST_HAS_SAME_DISTRIBUTION_COLUMN_SIZE,
- distributionColTypes.size());
+ info.getDistributionColumns().size(),
distributionColTypes.size());
}
// distribution col type
for (int i = 0; i < distributionColTypes.size(); i++) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/clone/DynamicPartitionScheduler.java
b/fe/fe-core/src/main/java/org/apache/doris/clone/DynamicPartitionScheduler.java
index 872be38de58..770e1298808 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/clone/DynamicPartitionScheduler.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/clone/DynamicPartitionScheduler.java
@@ -39,7 +39,6 @@ import org.apache.doris.catalog.PartitionKey;
import org.apache.doris.catalog.RangePartitionInfo;
import org.apache.doris.catalog.RangePartitionItem;
import org.apache.doris.catalog.Table;
-import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.FeConstants;
@@ -101,9 +100,9 @@ public class DynamicPartitionScheduler extends MasterDaemon
{
this.initialize = false;
}
- public void executeDynamicPartitionFirstTime(Long dbId, Long tableId) {
+ public void executeDynamicPartitionFirstTime(Long dbId, Long tableId)
throws DdlException {
List<Pair<Long, Long>> tempDynamicPartitionTableInfo =
Lists.newArrayList(Pair.of(dbId, tableId));
- executeDynamicPartition(tempDynamicPartitionTableInfo);
+ executeDynamicPartition(tempDynamicPartitionTableInfo, true);
}
public void registerDynamicPartitionTable(Long dbId, Long tableId) {
@@ -185,8 +184,9 @@ public class DynamicPartitionScheduler extends MasterDaemon
{
}
}
- private static int getBucketsNum(DynamicPartitionProperty property,
OlapTable table, String nowPartitionName) {
- if (!table.isAutoBucket()) {
+ private static int getBucketsNum(DynamicPartitionProperty property,
OlapTable table,
+ String nowPartitionName, boolean executeFirstTime) {
+ if (!table.isAutoBucket() || executeFirstTime) {
return property.getBuckets();
}
@@ -216,7 +216,7 @@ public class DynamicPartitionScheduler extends MasterDaemon
{
}
private ArrayList<AddPartitionClause> getAddPartitionClause(Database db,
OlapTable olapTable,
- Column partitionColumn, String partitionFormat) {
+ Column partitionColumn, String partitionFormat, boolean
executeFirstTime) throws DdlException {
ArrayList<AddPartitionClause> addPartitionClauses = new ArrayList<>();
DynamicPartitionProperty dynamicPartitionProperty =
olapTable.getTableProperty().getDynamicPartitionProperty();
RangePartitionInfo rangePartitionInfo = (RangePartitionInfo)
olapTable.getPartitionInfo();
@@ -224,15 +224,10 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
boolean createHistoryPartition =
dynamicPartitionProperty.isCreateHistoryPartition();
int idx;
- int start = dynamicPartitionProperty.getStart();
- int historyPartitionNum =
dynamicPartitionProperty.getHistoryPartitionNum();
// When enable create_history_partition, will check the valid value
from start and history_partition_num.
if (createHistoryPartition) {
- if (historyPartitionNum ==
DynamicPartitionProperty.NOT_SET_HISTORY_PARTITION_NUM) {
- idx = start;
- } else {
- idx = Math.max(start, -historyPartitionNum);
- }
+ idx =
DynamicPartitionUtil.getRealStart(dynamicPartitionProperty.getStart(),
+ dynamicPartitionProperty.getHistoryPartitionNum());
} else {
idx = 0;
}
@@ -261,12 +256,14 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
PartitionKey upperBound =
PartitionKey.createPartitionKey(Collections.singletonList(upperValue),
Collections.singletonList(partitionColumn));
addPartitionKeyRange = Range.closedOpen(lowerBound,
upperBound);
- } catch (AnalysisException | IllegalArgumentException e) {
+ } catch (Exception e) {
// AnalysisException: keys.size is always equal to
column.size, cannot reach this exception
// IllegalArgumentException: lb is greater than ub
- LOG.warn("Error in gen addPartitionKeyRange. Error={}, db: {},
table: {}", e.getMessage(),
- db.getFullName(), olapTable.getName());
- continue;
+ LOG.warn("Error in gen addPartitionKeyRange. db: {}, table:
{}, partition idx: {}",
+ db.getFullName(), olapTable.getName(), idx, e);
+ recordCreatePartitionFailedMsg(db.getFullName(),
olapTable.getName(),
+ e.getMessage(), olapTable.getId());
+ throw new DdlException(e.getMessage());
}
for (PartitionItem partitionItem :
rangePartitionInfo.getIdToItem(false).values()) {
// only support single column partition now
@@ -276,13 +273,16 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
isPartitionExists = true;
if (addPartitionKeyRange.equals(partitionItem.getItems()))
{
if (LOG.isDebugEnabled()) {
- LOG.debug("partition range {} exist in table {},
clear fail msg",
- addPartitionKeyRange, olapTable.getName());
+ LOG.debug("partition range {} exist in db {} table
{} partition idx {}, clear fail msg",
+ addPartitionKeyRange, db.getFullName(),
olapTable.getName(), idx);
}
clearCreatePartitionFailedMsg(olapTable.getId());
} else {
+ LOG.warn("check partition range {} in db {} table {}
partiton idx {} fail",
+ addPartitionKeyRange, db.getFullName(),
olapTable.getName(), idx, e);
recordCreatePartitionFailedMsg(db.getFullName(),
olapTable.getName(),
e.getMessage(), olapTable.getId());
+ throw new DdlException(e.getMessage());
}
break;
}
@@ -318,7 +318,7 @@ public class DynamicPartitionScheduler extends MasterDaemon
{
DistributionDesc distributionDesc = null;
DistributionInfo distributionInfo =
olapTable.getDefaultDistributionInfo();
- int bucketsNum = getBucketsNum(dynamicPartitionProperty,
olapTable, nowPartitionName);
+ int bucketsNum = getBucketsNum(dynamicPartitionProperty,
olapTable, nowPartitionName, executeFirstTime);
if (distributionInfo.getType() ==
DistributionInfo.DistributionInfoType.HASH) {
HashDistributionInfo hashDistributionInfo =
(HashDistributionInfo) distributionInfo;
List<String> distColumnNames = new ArrayList<>();
@@ -392,11 +392,11 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
PartitionKey upperBorderBound = PartitionKey.createPartitionKey(
Collections.singletonList(upperBorderPartitionValue),
Collections.singletonList(partitionColumn));
reservedHistoryPartitionKeyRange = Range.closed(lowerBorderBound,
upperBorderBound);
- } catch (AnalysisException e) {
+ } catch (org.apache.doris.common.AnalysisException |
org.apache.doris.nereids.exceptions.AnalysisException e) {
// AnalysisException: keys.size is always equal to column.size,
cannot reach this exception
// IllegalArgumentException: lb is greater than ub
- LOG.warn("Error in gen reservePartitionKeyRange. Error={}, db: {},
table: {}", e.getMessage(),
- db.getFullName(), olapTable.getName());
+ LOG.warn("Error in gen reservePartitionKeyRange. {}, table: {}",
+ db.getFullName(), olapTable.getName(), e);
}
return reservedHistoryPartitionKeyRange;
}
@@ -414,9 +414,11 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
return dropPartitionClauses;
}
+ int realStart =
DynamicPartitionUtil.getRealStart(dynamicPartitionProperty.getStart(),
+ dynamicPartitionProperty.getHistoryPartitionNum());
ZonedDateTime now =
ZonedDateTime.now(dynamicPartitionProperty.getTimeZone().toZoneId());
String lowerBorder =
DynamicPartitionUtil.getPartitionRangeString(dynamicPartitionProperty,
- now, dynamicPartitionProperty.getStart(), partitionFormat);
+ now, realStart, partitionFormat);
String upperBorder =
DynamicPartitionUtil.getPartitionRangeString(dynamicPartitionProperty,
now, dynamicPartitionProperty.getEnd() + 1, partitionFormat);
PartitionValue lowerPartitionValue = new PartitionValue(lowerBorder);
@@ -430,11 +432,12 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
Collections.singletonList(partitionColumn));
reservePartitionKeyRange = Range.closedOpen(lowerBound,
upperBound);
reservedHistoryPartitionKeyRangeList.add(reservePartitionKeyRange);
- } catch (AnalysisException | IllegalArgumentException e) {
+ } catch (Exception e) {
// AnalysisException: keys.size is always equal to column.size,
cannot reach this exception
// IllegalArgumentException: lb is greater than ub
- LOG.warn("Error in gen reservePartitionKeyRange. Error={}, db: {},
table: {}", e.getMessage(),
- db.getFullName(), olapTable.getName());
+ LOG.warn("Error in gen reservePartitionKeyRange. db: {}, table:
{}",
+ db.getFullName(), olapTable.getName(), e);
+ recordDropPartitionFailedMsg(db.getFullName(),
olapTable.getName(), e.getMessage(), olapTable.getId());
return dropPartitionClauses;
}
@@ -455,7 +458,8 @@ public class DynamicPartitionScheduler extends MasterDaemon
{
reservedHistoryPartitionKeyRangeList.add(reservedHistoryPartitionKeyRange);
} catch (IllegalArgumentException e) {
return dropPartitionClauses;
- } catch (AnalysisException e) {
+ } catch (org.apache.doris.common.AnalysisException
+ |
org.apache.doris.nereids.exceptions.AnalysisException e) {
throw new DdlException(e.getMessage());
}
}
@@ -487,7 +491,8 @@ public class DynamicPartitionScheduler extends MasterDaemon
{
return dropPartitionClauses;
}
- private void executeDynamicPartition(Collection<Pair<Long, Long>>
dynamicPartitionTableInfoCol) {
+ private void executeDynamicPartition(Collection<Pair<Long, Long>>
dynamicPartitionTableInfoCol,
+ boolean executeFirstTime) throws DdlException {
Iterator<Pair<Long, Long>> iterator =
dynamicPartitionTableInfoCol.iterator();
while (iterator.hasNext()) {
Pair<Long, Long> tableInfo = iterator.next();
@@ -546,12 +551,16 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
}
if (!skipAddPartition) {
- addPartitionClauses = getAddPartitionClause(db, olapTable,
partitionColumn, partitionFormat);
+ addPartitionClauses = getAddPartitionClause(db, olapTable,
partitionColumn, partitionFormat,
+ executeFirstTime);
}
dropPartitionClauses = getDropPartitionClause(db, olapTable,
partitionColumn, partitionFormat);
tableName = olapTable.getName();
- } catch (DdlException e) {
- LOG.warn("should not happen", e);
+ } catch (Exception e) {
+ LOG.warn("has error", e);
+ if (executeFirstTime) {
+ throw new DdlException(e.getMessage());
+ }
} finally {
olapTable.readUnlock();
}
@@ -565,6 +574,10 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
clearDropPartitionFailedMsg(olapTable.getId());
} catch (Exception e) {
recordDropPartitionFailedMsg(db.getFullName(), tableName,
e.getMessage(), olapTable.getId());
+ LOG.warn("has error", e);
+ if (executeFirstTime) {
+ throw new DdlException(e.getMessage());
+ }
} finally {
olapTable.writeUnlock();
}
@@ -577,6 +590,10 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
clearCreatePartitionFailedMsg(olapTable.getId());
} catch (Exception e) {
recordCreatePartitionFailedMsg(db.getFullName(),
tableName, e.getMessage(), olapTable.getId());
+ LOG.warn("has error", e);
+ if (executeFirstTime) {
+ throw new DdlException(e.getMessage());
+ }
}
}
}
@@ -634,7 +651,14 @@ public class DynamicPartitionScheduler extends
MasterDaemon {
}
setInterval(Config.dynamic_partition_check_interval_seconds * 1000L);
if (Config.dynamic_partition_enable) {
- executeDynamicPartition(dynamicPartitionTableInfo);
+ try {
+ executeDynamicPartition(dynamicPartitionTableInfo, false);
+ } catch (Exception e) {
+ // previous had log DdlException
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("dynamic partition has error: ", e);
+ }
+ }
}
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
index 5fb617253e0..1d417e19b1b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
@@ -1113,9 +1113,9 @@ public enum ErrorCode {
ERR_COLOCATE_TABLE_MUST_HAS_SAME_REPLICATION_ALLOCATION(5063, new
byte[]{'4', '2', '0', '0', '0'},
"Colocate tables must have same replication allocation: %s"),
ERR_COLOCATE_TABLE_MUST_HAS_SAME_BUCKET_NUM(5063, new byte[]{'4', '2',
'0', '0', '0'},
- "Colocate tables must have same bucket num: %s"),
+ "Colocate tables must have same bucket num: %s should be %s"),
ERR_COLOCATE_TABLE_MUST_HAS_SAME_DISTRIBUTION_COLUMN_SIZE(5063, new
byte[]{'4', '2', '0', '0', '0'},
- "Colocate tables distribution columns size must be same : %s"),
+ "Colocate tables distribution columns size must be same: %s should
be %s"),
ERR_COLOCATE_TABLE_MUST_HAS_SAME_DISTRIBUTION_COLUMN_TYPE(5063, new
byte[]{'4', '2', '0', '0', '0'},
"Colocate tables distribution columns must have the same data
type: %s should be %s"),
ERR_COLOCATE_NOT_COLOCATE_TABLE(5064, new byte[]{'4', '2', '0', '0', '0'},
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java
index e26d0cbd9f2..22a77768b64 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java
@@ -577,21 +577,18 @@ public class DynamicPartitionUtil {
long expectCreatePartitionNum = 0;
if (!createHistoryPartition) {
start = 0;
- expectCreatePartitionNum = (long) end - start;
} else {
int historyPartitionNum =
Integer.parseInt(analyzedProperties.getOrDefault(
DynamicPartitionProperty.HISTORY_PARTITION_NUM,
String.valueOf(DynamicPartitionProperty.NOT_SET_HISTORY_PARTITION_NUM)));
- if (historyPartitionNum !=
DynamicPartitionProperty.NOT_SET_HISTORY_PARTITION_NUM) {
- expectCreatePartitionNum = (long) end - Math.max(start,
-historyPartitionNum);
- } else {
- if (start == Integer.MIN_VALUE) {
- throw new DdlException("Provide start or
history_partition_num property"
- + " when create_history_partition=true. Otherwise
set create_history_partition=false");
- }
- expectCreatePartitionNum = (long) end - start;
+ start = getRealStart(start, historyPartitionNum);
+ if (start == Integer.MIN_VALUE) {
+ throw new DdlException("Provide start or history_partition_num
property"
+ + " when create_history_partition=true. Otherwise set
create_history_partition=false");
}
}
+ expectCreatePartitionNum = (long) end - start;
+
if (hasEnd && (expectCreatePartitionNum >
Config.max_dynamic_partition_num)
&&
Boolean.parseBoolean(analyzedProperties.getOrDefault(DynamicPartitionProperty.ENABLE,
"true"))) {
throw new DdlException("Too many dynamic partitions: "
@@ -673,6 +670,14 @@ public class DynamicPartitionUtil {
return analyzedProperties;
}
+ public static int getRealStart(int start, int historyPartitionNum) {
+ if (historyPartitionNum ==
DynamicPartitionProperty.NOT_SET_HISTORY_PARTITION_NUM) {
+ return start;
+ } else {
+ return Math.max(start, -historyPartitionNum);
+ }
+ }
+
public static void checkAlterAllowed(OlapTable olapTable) throws
DdlException {
TableProperty tableProperty = olapTable.getTableProperty();
if (tableProperty != null &&
tableProperty.getDynamicPartitionProperty() != null
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java
b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java
index 924fcd53b7d..9eb21fb7f33 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java
@@ -138,11 +138,12 @@ public class AlterTest {
+ "PROPERTIES\n"
+ "(\n"
+ "\"colocate_with\" = \"group_3\",\n"
+ + "\"replication_num\" = \"1\",\n"
+ "\"dynamic_partition.enable\" = \"true\",\n"
+ "\"dynamic_partition.time_unit\" = \"DAY\",\n"
+ "\"dynamic_partition.end\" = \"3\",\n"
+ "\"dynamic_partition.prefix\" = \"p\",\n"
- + "\"dynamic_partition.buckets\" = \"32\",\n"
+ + "\"dynamic_partition.buckets\" = \"3\",\n"
+ "\"dynamic_partition.replication_num\" = \"1\",\n"
+ "\"dynamic_partition.create_history_partition\"=\"true\",\n"
+ "\"dynamic_partition.start\" = \"-3\"\n"
@@ -229,7 +230,12 @@ public class AlterTest {
private static void createTable(String sql) throws Exception {
Config.enable_odbc_table = true;
CreateTableStmt createTableStmt = (CreateTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(sql, connectContext);
- Env.getCurrentEnv().createTable(createTableStmt);
+ try {
+ Env.getCurrentEnv().createTable(createTableStmt);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
}
private static void createRemoteStorageResource(String sql) throws
Exception {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java
b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java
index cf3ddbf69c0..45628bbc315 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java
@@ -222,7 +222,7 @@ public class ColocateTableTest {
+ ");");
expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("Colocate tables must have same bucket num:
1");
+ expectedEx.expectMessage("Colocate tables must have same bucket num: 2
should be 1");
createTable("create table " + dbName + "." + tableName2 + " (\n"
+ " `k1` int NULL COMMENT \"\",\n"
+ " `k2` varchar(10) NULL COMMENT \"\"\n"
@@ -281,7 +281,7 @@ public class ColocateTableTest {
+ ");");
expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("Colocate tables distribution columns size
must be same : 2");
+ expectedEx.expectMessage("Colocate tables distribution columns size
must be same: 1 should be 2");
createTable("create table " + dbName + "." + tableName2 + " (\n"
+ " `k1` int NULL COMMENT \"\",\n"
+ " `k2` varchar(10) NULL COMMENT \"\"\n"
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java
b/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java
index f883f8928fc..5216899b02b 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java
@@ -67,6 +67,7 @@ public class DynamicPartitionTableTest {
FeConstants.default_scheduler_interval_millisecond = 1000;
FeConstants.runningUnitTest = true;
Config.disable_storage_medium_check = true;
+ Config.dynamic_partition_enable = false; // disable auto create
dynamic partition
UtFrameUtils.createDorisCluster(runningDir);
@@ -722,6 +723,25 @@ public class DynamicPartitionTableTest {
ExceptionChecker.expectThrowsNoException(() -> alterTable(alter4));
Env.getCurrentEnv().getDynamicPartitionScheduler().executeDynamicPartitionFirstTime(db.getId(),
tbl.getId());
Assert.assertEquals(24, tbl.getPartitionNames().size());
+
+ String createOlapTblStmt5 =
+ "CREATE TABLE test.`dynamic_partition4` (\n" + " `k1`
datetime NULL COMMENT \"\"\n" + ")\n"
+ + "PARTITION BY RANGE (k1)\n" + "()\n" + "DISTRIBUTED
BY HASH(`k1`) BUCKETS 1\n"
+ + "PROPERTIES (\n" + "\"replication_num\" = \"1\",\n"
+ + "\"dynamic_partition.enable\" = \"true\",\n" +
"\"dynamic_partition.end\" = \"3\",\n"
+ + "\"dynamic_partition.time_unit\" = \"day\",\n" +
"\"dynamic_partition.prefix\" = \"p\",\n"
+ + "\"dynamic_partition.buckets\" = \"1\",\n" +
"\"dynamic_partition.start\" = \"-99999999\",\n"
+ + "\"dynamic_partition.history_partition_num\" =
\"5\",\n"
+ + "\"dynamic_partition.create_history_partition\" =
\"true\"\n" + ");";
+ // start and history_partition_num are set, create ok
+ ExceptionChecker.expectThrowsNoException(() ->
createTable(createOlapTblStmt5));
+ OlapTable tbl4 = (OlapTable)
db.getTableOrAnalysisException("dynamic_partition4");
+ Assert.assertEquals(9, tbl4.getPartitionNames().size());
+
+ String alter5 = "alter table test.dynamic_partition4 set
('dynamic_partition.history_partition_num' = '3')";
+ ExceptionChecker.expectThrowsNoException(() -> alterTable(alter5));
+
Env.getCurrentEnv().getDynamicPartitionScheduler().executeDynamicPartitionFirstTime(db.getId(),
tbl4.getId());
+ Assert.assertEquals(7, tbl4.getPartitionNames().size());
}
@Test
diff --git a/regression-test/suites/delete_p0/test_delete.groovy
b/regression-test/suites/delete_p0/test_delete.groovy
index c7010b0604b..2b10cacb10d 100644
--- a/regression-test/suites/delete_p0/test_delete.groovy
+++ b/regression-test/suites/delete_p0/test_delete.groovy
@@ -265,21 +265,13 @@ PARTITION p202012 VALUES LESS THAN ('2021-01-01 00:00:00')
DISTRIBUTED BY HASH(`tenant_id`) BUCKETS auto
PROPERTIES
(
- "dynamic_partition.enable" = "true",
- "dynamic_partition.time_unit" = "MONTH",
- "dynamic_partition.end" = "2",
- "dynamic_partition.prefix" = "p",
- "dynamic_partition.start_day_of_month" = "1",
- "dynamic_partition.create_history_partition" = "true",
- "dynamic_partition.history_partition_num" = "120",
- "dynamic_partition.buckets"="1",
"estimate_partition_size" = "1G",
"storage_type" = "COLUMN",
"replication_num" = "1"
);
"""
- sql "delete from dwd_pay partitions(p202310) where pay_time = '20231002';"
+ sql "delete from dwd_pay partitions(p202012) where pay_time = '20231002';"
sql """
ADMIN SET FRONTEND CONFIG ('disable_decimalv2' = 'false');
diff --git a/regression-test/suites/index_p0/test_bitmap_index.groovy
b/regression-test/suites/index_p0/test_bitmap_index.groovy
index 8d438dc6085..e6f32462de4 100644
--- a/regression-test/suites/index_p0/test_bitmap_index.groovy
+++ b/regression-test/suites/index_p0/test_bitmap_index.groovy
@@ -345,19 +345,6 @@ suite("test_bitmap_index") {
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"is_being_synced" = "false",
- "dynamic_partition.enable" = "true",
- "dynamic_partition.time_unit" = "MONTH",
- "dynamic_partition.time_zone" = "Asia/Shanghai",
- "dynamic_partition.start" = "-30",
- "dynamic_partition.end" = "1",
- "dynamic_partition.prefix" = "p",
- "dynamic_partition.replication_allocation" =
"tag.location.default: 1",
- "dynamic_partition.buckets" = "10",
- "dynamic_partition.create_history_partition" = "true",
- "dynamic_partition.history_partition_num" = "-1",
- "dynamic_partition.hot_partition_num" = "0",
- "dynamic_partition.reserved_history_periods" = "NULL",
- "dynamic_partition.storage_policy" = "",
"storage_format" = "V2",
"enable_unique_key_merge_on_write" = "false",
"light_schema_change" = "true",
@@ -447,19 +434,6 @@ suite("test_bitmap_index") {
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"is_being_synced" = "false",
- "dynamic_partition.enable" = "true",
- "dynamic_partition.time_unit" = "MONTH",
- "dynamic_partition.time_zone" = "Asia/Shanghai",
- "dynamic_partition.start" = "-30",
- "dynamic_partition.end" = "1",
- "dynamic_partition.prefix" = "p",
- "dynamic_partition.replication_allocation" =
"tag.location.default: 1",
- "dynamic_partition.buckets" = "10",
- "dynamic_partition.create_history_partition" = "true",
- "dynamic_partition.history_partition_num" = "-1",
- "dynamic_partition.hot_partition_num" = "0",
- "dynamic_partition.reserved_history_periods" = "NULL",
- "dynamic_partition.storage_policy" = "",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
diff --git
a/regression-test/suites/partition_p0/dynamic_partition/test_dynamic_partition_failed.groovy
b/regression-test/suites/partition_p0/dynamic_partition/test_dynamic_partition_failed.groovy
new file mode 100644
index 00000000000..7da145a36bc
--- /dev/null
+++
b/regression-test/suites/partition_p0/dynamic_partition/test_dynamic_partition_failed.groovy
@@ -0,0 +1,74 @@
+// 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_dynamic_partition_failed', 'nonConcurrent') {
+ def old_max_dynamic_partition_num =
getFeConfig('max_dynamic_partition_num')
+ try {
+ sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_1'
+ sql '''CREATE TABLE test_dynamic_partition_failed_1
+ ( `k1` datetime NULL )
+ PARTITION BY RANGE (k1)()
+ DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+ PROPERTIES
+ (
+ "replication_num" = "1",
+ "dynamic_partition.enable" = "true",
+ "dynamic_partition.end" = "3",
+ "dynamic_partition.time_unit" = "day",
+ "dynamic_partition.prefix" = "p",
+ "dynamic_partition.buckets" = "1",
+ "dynamic_partition.start" = "-99999999",
+ "dynamic_partition.history_partition_num" = "5",
+ "dynamic_partition.create_history_partition" = "true"
+ )'''
+
+ def partitions = sql_return_maparray "SHOW PARTITIONS FROM
test_dynamic_partition_failed_1"
+ assertEquals(9, partitions.size());
+
+ setFeConfig('max_dynamic_partition_num', Integer.MAX_VALUE)
+
+ sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_2'
+ test {
+ sql '''CREATE TABLE test_dynamic_partition_failed_2
+ ( `k1` datetime NULL )
+ PARTITION BY RANGE (k1)()
+ DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+ PROPERTIES
+ (
+ "replication_num" = "1",
+ "dynamic_partition.enable" = "true",
+ "dynamic_partition.end" = "3",
+ "dynamic_partition.time_unit" = "day",
+ "dynamic_partition.prefix" = "p",
+ "dynamic_partition.buckets" = "1",
+ "dynamic_partition.start" = "-99999999",
+ "dynamic_partition.create_history_partition" = "true"
+ )'''
+ check { result, exception, startTime, endTime ->
+ assertNotNull(exception)
+ def msg = exception.toString()
+ logger.info("exception: " + msg)
+ // 'date/datetime literal [+271768-09-11 00:00:00] is invalid'
+ assertTrue(msg.contains('date/datetime literal') &&
msg.contains('is invalid'))
+ }
+ }
+ } finally {
+ setFeConfig('max_dynamic_partition_num', old_max_dynamic_partition_num)
+ sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_1'
+ sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_2'
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]