diff --git a/be/src/olap/partial_update_info.cpp b/be/src/olap/partial_update_info.cpp index e751e98b812997..1ca269a0f317b7 100644 --- a/be/src/olap/partial_update_info.cpp +++ b/be/src/olap/partial_update_info.cpp @@ -50,28 +50,18 @@ Status PartialUpdateInfo::init(int64_t tablet_id, int64_t txn_id, const TabletSc missing_cids.clear(); update_cids.clear(); - // partial_update_cols should include all key columns - for (std::size_t i {0}; i < tablet_schema.num_key_columns(); i++) { - const auto key_col = tablet_schema.column(i); - if (!partial_update_cols.contains(key_col.name())) { - auto msg = fmt::format( - "Unable to do partial update on shadow index's tablet, tablet_id={}, " - "txn_id={}. Missing key column {}.", - tablet_id, txn_id, key_col.name()); - LOG_WARNING(msg); - return Status::Aborted(msg); - } - } - - // every including columns should be in tablet_schema - for (const auto& col : partial_update_cols) { - if (-1 == tablet_schema.field_index(col)) { - auto msg = fmt::format( - "Unable to do partial update on shadow index's tablet, tablet_id={}, " - "txn_id={}. Can't find column {} in tablet's schema.", - tablet_id, txn_id, col); - LOG_WARNING(msg); - return Status::Aborted(msg); + if (partial_update_mode == UniqueKeyUpdateModePB::UPDATE_FIXED_COLUMNS) { + // partial_update_cols should include all key columns + for (std::size_t i {0}; i < tablet_schema.num_key_columns(); i++) { + const auto key_col = tablet_schema.column(i); + if (!partial_update_cols.contains(key_col.name())) { + auto msg = fmt::format( + "Unable to do partial update on shadow index's tablet, tablet_id={}, " + "txn_id={}. Missing key column {}.", + tablet_id, txn_id, key_col.name()); + LOG_WARNING(msg); + return Status::Aborted(msg); + } } } diff --git a/regression-test/data/fault_injection_p0/partial_update/test_add_key_partial_update.out b/regression-test/data/fault_injection_p0/partial_update/test_add_key_partial_update.out index ffbfdce8b4794a..87d44dac59e4f4 100644 --- a/regression-test/data/fault_injection_p0/partial_update/test_add_key_partial_update.out +++ b/regression-test/data/fault_injection_p0/partial_update/test_add_key_partial_update.out @@ -9,11 +9,8 @@ -- !sql -- 1 \N 1 1 2 0 -1 \N \N \N 6 1 2 \N 2 2 2 0 -2 \N \N \N 6 1 3 \N 3 3 2 0 -3 \N \N \N 6 1 4 \N 4 4 5 0 5 \N 5 5 5 0 6 \N 6 6 5 0 diff --git a/regression-test/suites/fault_injection_p0/partial_update/test_add_key_partial_update.groovy b/regression-test/suites/fault_injection_p0/partial_update/test_add_key_partial_update.groovy index eb7d951610288e..61ba9d60ea8371 100644 --- a/regression-test/suites/fault_injection_p0/partial_update/test_add_key_partial_update.groovy +++ b/regression-test/suites/fault_injection_p0/partial_update/test_add_key_partial_update.groovy @@ -51,7 +51,10 @@ suite("test_add_key_partial_update", "nonConcurrent") { sql "alter table ${table1} ADD COLUMN k2 int key;" Thread.sleep(1000) - sql "delete from ${table1} where k1<=3;" + test { + sql "delete from ${table1} where k1<=3;" + exception "Unable to do partial update on shadow index's tablet" + } waitForSchemaChangeDone { sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${table1}' ORDER BY createtime DESC LIMIT 1 """