This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new b27731e469f branch-3.1: [fix](cloud-mow) Commit transaction should
fail when partition has been droped #49205 (#52215)
b27731e469f is described below
commit b27731e469fa3c7738f2be53bda8601144ac6aa6
Author: meiyi <[email protected]>
AuthorDate: Wed Jun 25 14:13:45 2025 +0800
branch-3.1: [fix](cloud-mow) Commit transaction should fail when partition
has been droped #49205 (#52215)
Cherry-pick from #49205
Co-authored-by: huanghaibin <[email protected]>
---
.../transaction/CloudGlobalTransactionMgr.java | 10 +++-
.../mow_insert_with_partition_drop.groovy | 67 ++++++++++++++++++++++
2 files changed, 74 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java
index 520539d0704..d3762721e05 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java
@@ -762,7 +762,7 @@ public class CloudGlobalTransactionMgr implements
GlobalTransactionMgrIface {
private void getPartitionInfo(List<OlapTable> tableList,
List<TabletCommitInfo> tabletCommitInfos,
- DeleteBitmapUpdateLockContext lockContext) {
+ DeleteBitmapUpdateLockContext lockContext) throws
MetaNotFoundException {
Map<Long, OlapTable> tableMap = Maps.newHashMap();
for (OlapTable olapTable : tableList) {
tableMap.put(olapTable.getId(), olapTable);
@@ -802,7 +802,11 @@ public class CloudGlobalTransactionMgr implements
GlobalTransactionMgrIface {
partitionToTablets.put(partitionId, Lists.newArrayList());
}
partitionToTablets.get(partitionId).add(tabletIds.get(i));
- lockContext.getPartitions().putIfAbsent(partitionId,
tableMap.get(tableId).getPartition(partitionId));
+ Partition partition =
tableMap.get(tableId).getPartition(partitionId);
+ if (partition == null) {
+ throw new MetaNotFoundException("partition " + partitionId + "
does not exist");
+ }
+ lockContext.getPartitions().putIfAbsent(partitionId, partition);
}
}
@@ -1290,7 +1294,7 @@ public class CloudGlobalTransactionMgr implements
GlobalTransactionMgrIface {
TxnCommitAttachment
txnCommitAttachment) throws UserException {
for (int i = 0; i < tableList.size(); i++) {
long tableId = tableList.get(i).getId();
- LOG.info("start commit txn=" + transactionId + ",table=" +
tableId);
+ LOG.info("start commit txn=" + transactionId + ",table=" + tableId
+ ",timeoutMillis=" + timeoutMillis);
}
for (Map.Entry<Long, AtomicInteger> entry :
waitToCommitTxnCountMap.entrySet()) {
if (entry.getValue().get() > 5) {
diff --git
a/regression-test/suites/insert_p0/mow_insert_with_partition_drop.groovy
b/regression-test/suites/insert_p0/mow_insert_with_partition_drop.groovy
new file mode 100644
index 00000000000..8f9c6d97a54
--- /dev/null
+++ b/regression-test/suites/insert_p0/mow_insert_with_partition_drop.groovy
@@ -0,0 +1,67 @@
+// 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("mow_insert_with_partition_drop") {
+ def table = "mow_insert_with_partition_drop"
+ // create table and insert data
+ sql """ drop table if exists ${table}"""
+ sql """
+ create table ${table} (
+ `da` date,
+ `id` int(11),
+ `name` varchar(128)
+ )
+ engine=olap
+ unique key(da)
+ partition by range(da)(
+ PARTITION p3 VALUES LESS THAN ('2023-01-01'),
+ PARTITION p4 VALUES LESS THAN ('2024-01-01'),
+ PARTITION p5 VALUES LESS THAN ('2025-01-01')
+ )
+ distributed by hash(da) buckets 2
+ properties(
+ "replication_num"="1",
+ "light_schema_change"="true"
+ );
+ """
+ def do_insert_into = {
+ int j = 1
+ while (j < 30) {
+ try {
+ logger.info("round=" + j)
+ sql """ insert into ${table} values('2022-01-02', 2, 'a'); """
+ sql """ insert into ${table} values('2023-01-02', 2, 'a'); """
+ sql """ insert into ${table} values('2024-01-02', 3, 'a'); """
+ j++
+ } catch (Exception e) {
+ logger.info("exception=" + e.getMessage())
+ assertTrue(e.getMessage().contains("Insert has filtered data
in strict mode. url:") ||
+ (e.getMessage().contains("partition") &&
e.getMessage().contains("does not exist")))
+ }
+
+ }
+ }
+
+ def t1 = Thread.startDaemon {
+ do_insert_into()
+ }
+ for (int i = 0; i < 30; i++) {
+ sql """ ALTER TABLE ${table} DROP PARTITION p3 force; """
+ sql """ ALTER TABLE ${table} ADD PARTITION p3 VALUES LESS THAN
('2023-01-01'); """
+ }
+ t1.join()
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]