[fix](catalog recycle bin) table partition meta is error if recover partition in some case (#31125)

This commit is contained in:
meiyi
2024-02-20 16:28:52 +08:00
committed by yiguolei
parent 4735c5b50f
commit 0ab8143565
4 changed files with 69 additions and 6 deletions

View File

@ -799,10 +799,9 @@ public class CatalogRecycleBin extends MasterDaemon implements Writable {
}
PartitionInfo partitionInfo = table.getPartitionInfo();
Range<PartitionKey> recoverRange = recoverPartitionInfo.getRange();
PartitionItem recoverItem = null;
if (partitionInfo.getType() == PartitionType.RANGE) {
recoverItem = new RangePartitionItem(recoverRange);
recoverItem = new RangePartitionItem(recoverPartitionInfo.getRange());
} else if (partitionInfo.getType() == PartitionType.LIST) {
recoverItem = recoverPartitionInfo.getListPartitionItem();
}
@ -811,18 +810,18 @@ public class CatalogRecycleBin extends MasterDaemon implements Writable {
throw new DdlException("Can not recover partition[" + partitionName + "]. Partition item conflict.");
}
// recover partition
// check if partition name exists
Partition recoverPartition = recoverPartitionInfo.getPartition();
Preconditions.checkState(recoverPartition.getName().equalsIgnoreCase(partitionName));
if (!Strings.isNullOrEmpty(newPartitionName)) {
if (table.checkPartitionNameExist(newPartitionName)) {
throw new DdlException("Partition name[" + newPartitionName + "] is already used");
}
recoverPartition.setName(newPartitionName);
}
// recover partition
table.addPartition(recoverPartition);
if (!Strings.isNullOrEmpty(newPartitionName)) {
table.renamePartition(partitionName, newPartitionName);
}
// recover partition info
long partitionId = recoverPartition.getId();