Skip to content

Commit

Permalink
[case](cloud) add case that partial update fail to update tmp rowset …
Browse files Browse the repository at this point in the history
…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 #45626
is merged.
  • Loading branch information
bobhan1 authored and Your Name committed Dec 25, 2024
1 parent edc9ca4 commit a70df99
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
3 changes: 3 additions & 0 deletions be/src/cloud/cloud_tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<false>("injected update_tmp_rowset error.");
});
const auto& rowset_meta = rowset->rowset_meta();
RETURN_IF_ERROR(_engine.meta_mgr().update_tmp_rowset(*rowset_meta));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit a70df99

Please sign in to comment.