Skip to content

Commit 832fec6

Browse files
authored
branch-4.0: [fix](insert-overwrite) skip deleted partitions before replace to avoid DdlException #60914 (#60949)
picked from #60914
1 parent 5c97bb5 commit 832fec6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/insertoverwrite/InsertOverwriteUtil.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,21 @@ public static void replacePartition(TableIf olapTable, List<String> partitionNam
7979
if (!olapTable.writeLockIfExist()) {
8080
return;
8181
}
82+
// Filter out partitions that were deleted between the snapshot time and now.
83+
// The write lock is held here, so this check and the subsequent replace are atomic.
84+
// The temp partition list is kept as-is so all written data remains visible.
85+
List<String> validPartitionNames = new ArrayList<>();
86+
for (int i = 0; i < partitionNames.size(); i++) {
87+
if (((OlapTable) olapTable).checkPartitionNameExist(partitionNames.get(i), false)) {
88+
validPartitionNames.add(partitionNames.get(i));
89+
} else {
90+
LOG.warn("partition [{}] has been deleted before replace, skipping", partitionNames.get(i));
91+
}
92+
}
8293
Map<String, String> properties = Maps.newHashMap();
8394
properties.put(PropertyAnalyzer.PROPERTIES_USE_TEMP_PARTITION_NAME, "false");
8495
ReplacePartitionClause replacePartitionClause = new ReplacePartitionClause(
85-
new PartitionNamesInfo(false, partitionNames),
96+
new PartitionNamesInfo(false, validPartitionNames),
8697
new PartitionNamesInfo(true, tempPartitionNames), isForce, properties);
8798
if (replacePartitionClause.getTempPartitionNames().isEmpty()) {
8899
return;

0 commit comments

Comments
 (0)