From a70df99ab583541ae0207499aace2fe6d00382a3 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Wed, 25 Dec 2024 22:18:20 +0800 Subject: [PATCH] [case](cloud) add case that partial update fail to update tmp rowset after it write new segment in publish phase (#45795) add a case that partial update fail to update tmp rowset after it write a new segment in publish phase. The inverted checker is expected to fail because of this case before https://github.com/apache/doris/pull/45626 is merged. --- be/src/cloud/cloud_tablet.cpp | 3 + ..._partial_update_update_tmp_rowset_fail.out | 11 +++ ...rtial_update_update_tmp_rowset_fail.groovy | 93 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 regression-test/data/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.out create mode 100644 regression-test/suites/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.groovy diff --git a/be/src/cloud/cloud_tablet.cpp b/be/src/cloud/cloud_tablet.cpp index 4325d568b55fe3..2518287ba7c8a8 100644 --- a/be/src/cloud/cloud_tablet.cpp +++ b/be/src/cloud/cloud_tablet.cpp @@ -716,6 +716,9 @@ Status CloudTablet::save_delete_bitmap(const TabletTxnInfo* txn_info, int64_t tx if (txn_info->partial_update_info && txn_info->partial_update_info->is_partial_update && rowset_writer->num_rows() > 0) { + DBUG_EXECUTE_IF("CloudTablet::save_delete_bitmap.update_tmp_rowset.error", { + return Status::InternalError("injected update_tmp_rowset error."); + }); const auto& rowset_meta = rowset->rowset_meta(); RETURN_IF_ERROR(_engine.meta_mgr().update_tmp_rowset(*rowset_meta)); } diff --git a/regression-test/data/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.out b/regression-test/data/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.out new file mode 100644 index 00000000000000..c01f2d185c86be --- /dev/null +++ b/regression-test/data/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.out @@ -0,0 +1,11 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- +1 1 1 1 +2 2 2 2 +3 3 3 2 + +-- !sql -- +1 999 1 1 +2 666 2 2 +3 3 3 2 + diff --git a/regression-test/suites/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.groovy b/regression-test/suites/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.groovy new file mode 100644 index 00000000000000..45c2c9b4a82ced --- /dev/null +++ b/regression-test/suites/fault_injection_p0/cloud/test_cloud_partial_update_update_tmp_rowset_fail.groovy @@ -0,0 +1,93 @@ +// 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_cloud_partial_update_update_tmp_rowset_fail", "nonConcurrent") { + if (!isCloudMode()) { + return + } + + GetDebugPoint().clearDebugPointsForAllFEs() + GetDebugPoint().clearDebugPointsForAllBEs() + + + def table1 = "test_partial_update_update_tmp_rowset_fail" + sql "DROP TABLE IF EXISTS ${table1} FORCE;" + sql """ CREATE TABLE IF NOT EXISTS ${table1} ( + `k1` int NOT NULL, + `c1` int, + `c2` int, + `c3` int + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "enable_unique_key_merge_on_write" = "true", + "disable_auto_compaction" = "true", + "replication_num" = "1"); """ + + sql "insert into ${table1} values(1,1,1,1);" + sql "insert into ${table1} values(2,2,2,2);" + sql "insert into ${table1} values(3,3,3,2);" + sql "sync;" + qt_sql "select * from ${table1} order by k1;" + + try { + // let two partial update load have conflicts + GetDebugPoint().enableDebugPointForAllFEs("CloudGlobalTransactionMgr.getDeleteBitmapUpdateLock.enable_spin_wait") + GetDebugPoint().enableDebugPointForAllFEs("CloudGlobalTransactionMgr.getDeleteBitmapUpdateLock.block") + + // this will case the older partial update fail in publish phase after it write a new segment due to conflict + // and before it updates the num_segments field of tmp rowset's meta + GetDebugPoint().enableDebugPointForAllBEs("CloudTablet::save_delete_bitmap.update_tmp_rowset.error") + + def t1 = Thread.start { + try { + sql "set enable_unique_key_partial_update=true;" + sql "sync;" + sql "insert into ${table1}(k1,c1) values(1,999),(2,666);" + } catch(Exception e) { + logger.info(e.getMessage()) + } + } + Thread.sleep(800) + + def t2 = Thread.start { + try { + sql "set enable_unique_key_partial_update=true;" + sql "sync;" + sql "insert into ${table1}(k1,c2) values(1,888),(2,777);" + } catch(Exception e) { + logger.info(e.getMessage()) + } + } + Thread.sleep(800) + + + GetDebugPoint().disableDebugPointForAllFEs("CloudGlobalTransactionMgr.getDeleteBitmapUpdateLock.enable_spin_wait") + GetDebugPoint().disableDebugPointForAllFEs("CloudGlobalTransactionMgr.getDeleteBitmapUpdateLock.block") + + + t1.join() + t2.join() + + qt_sql "select * from ${table1} order by k1;" + } catch(Exception e) { + logger.info(e.getMessage()) + throw e + } finally { + GetDebugPoint().clearDebugPointsForAllBEs() + } +}