[fix](dynamic partition) drop partition exclude history_partition_num #37539 (#37570)

cherry pick from #37539

---------

Co-authored-by: Yongqiang YANG <98214048+dataroaring@users.noreply.github.com>
This commit is contained in:
yujun
2024-07-10 22:09:00 +08:00
committed by GitHub
parent a54ba2ea63
commit f58032f1da
3 changed files with 29 additions and 13 deletions

View File

@ -432,8 +432,10 @@ public class DynamicPartitionScheduler extends MasterDaemon {
return dropPartitionClauses;
}
int realStart = DynamicPartitionUtil.getRealStart(dynamicPartitionProperty.getStart(),
dynamicPartitionProperty.getHistoryPartitionNum());
// drop partition only considering start, not considering history_partition_num.
// int realStart = DynamicPartitionUtil.getRealStart(dynamicPartitionProperty.getStart(),
// dynamicPartitionProperty.getHistoryPartitionNum());
int realStart = dynamicPartitionProperty.getStart();
ZonedDateTime now = ZonedDateTime.now(dynamicPartitionProperty.getTimeZone().toZoneId());
String lowerBorder = DynamicPartitionUtil.getPartitionRangeString(dynamicPartitionProperty,
now, realStart, partitionFormat);
@ -448,9 +450,12 @@ public class DynamicPartitionScheduler extends MasterDaemon {
} 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. db: {}, table: {}",
db.getFullName(), olapTable.getName(), e);
recordDropPartitionFailedMsg(db.getFullName(), olapTable.getName(), e.getMessage(), olapTable.getId());
String hint = "'dynamic_partition.start' = " + dynamicPartitionProperty.getStart()
+ ", maybe it's too small, can use alter table sql to increase it. ";
LOG.warn("Error in gen reservePartitionKeyRange. db: {}, table: {}. {}",
db.getFullName(), olapTable.getName(), hint, e);
recordDropPartitionFailedMsg(db.getFullName(), olapTable.getName(), hint + ", error: " + e.getMessage(),
olapTable.getId());
return dropPartitionClauses;
}
@ -569,10 +574,12 @@ public class DynamicPartitionScheduler extends MasterDaemon {
addPartitionClauses = getAddPartitionClause(db, olapTable, partitionColumn, partitionFormat,
executeFirstTime);
}
clearDropPartitionFailedMsg(olapTable.getId());
dropPartitionClauses = getDropPartitionClause(db, olapTable, partitionColumn, partitionFormat);
tableName = olapTable.getName();
} catch (Exception e) {
LOG.warn("has error", e);
LOG.warn("db [{}-{}], table [{}-{}]'s dynamic partition has error",
db.getId(), db.getFullName(), olapTable.getId(), olapTable.getName(), e);
if (executeFirstTime) {
throw new DdlException(e.getMessage());
}
@ -586,10 +593,10 @@ public class DynamicPartitionScheduler extends MasterDaemon {
}
try {
Env.getCurrentEnv().dropPartition(db, olapTable, dropPartitionClause);
clearDropPartitionFailedMsg(olapTable.getId());
} catch (Exception e) {
recordDropPartitionFailedMsg(db.getFullName(), tableName, e.getMessage(), olapTable.getId());
LOG.warn("has error", e);
LOG.warn("db [{}-{}], table [{}-{}]'s dynamic partition has error",
db.getId(), db.getFullName(), olapTable.getId(), olapTable.getName(), e);
if (executeFirstTime) {
throw new DdlException(e.getMessage());
}