From 89bce4b727631bff6be1bef13de11adef3f95d81 Mon Sep 17 00:00:00 2001 From: HoniiTro19 Date: Wed, 11 Dec 2024 03:46:38 +0000 Subject: [PATCH] add cases for delayed column transform --- .../oblib/src/lib/utility/ob_tracepoint_def.h | 1 + src/rootserver/ob_ddl_service.cpp | 4 ++-- src/share/schema/ob_schema_utils.cpp | 20 +++++++++++++++---- src/share/schema/ob_table_param.cpp | 2 +- src/share/schema/ob_table_schema.cpp | 2 +- .../ddl/ob_create_table_resolver_base.cpp | 16 ++++++++++++--- .../compaction/ob_medium_compaction_func.cpp | 2 +- 7 files changed, 35 insertions(+), 12 deletions(-) diff --git a/deps/oblib/src/lib/utility/ob_tracepoint_def.h b/deps/oblib/src/lib/utility/ob_tracepoint_def.h index d927afcc5..c4fe3e8f2 100644 --- a/deps/oblib/src/lib/utility/ob_tracepoint_def.h +++ b/deps/oblib/src/lib/utility/ob_tracepoint_def.h @@ -351,6 +351,7 @@ GLOBAL_ERRSIM_POINT_DEF(519, EN_DDL_EXECUTE_FAILED, ""); GLOBAL_ERRSIM_POINT_DEF(520, EN_DDL_RETRY_WRITE_SLICE_AFTER_SUCC, ""); GLOBAL_ERRSIM_POINT_DEF(521, EN_BLOCK_SPLIT_BEFORE_SSTABLES_SPLIT, ""); GLOBAL_ERRSIM_POINT_DEF(522, EN_BLOCK_LOB_SPLIT_BEFORE_SSTABLES_SPLIT, ""); +GLOBAL_ERRSIM_POINT_DEF(523, EN_DDL_CREATE_OLD_VERSION_COLUMN_GROUP, ""); // vec index GLOBAL_ERRSIM_POINT_DEF(530, EN_VEC_INDEX_DROP_SHARE_TABLE_ERR, ""); diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index 6b6e066b0..b394745be 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -14395,8 +14395,8 @@ int ObDDLService::alter_table_in_trans(obrpc::ObAlterTableArg &alter_table_arg, trans))) { LOG_WARN("failed to alter table column group table", K(ret)); } else { - // only change schemas here, leave data reshaping in daily merge - LOG_DEBUG("alter column group in trans", K(ret), K(new_table_schema)); + // only change schemas here, leave data reshaping in major merge + LOG_INFO("alter column group delayed", K(ret), KPC(orig_table_schema), K(new_table_schema)); } } diff --git a/src/share/schema/ob_schema_utils.cpp b/src/share/schema/ob_schema_utils.cpp index e18ce2e80..e74fadb36 100644 --- a/src/share/schema/ob_schema_utils.cpp +++ b/src/share/schema/ob_schema_utils.cpp @@ -816,11 +816,18 @@ int ObSchemaUtils::alter_rowkey_column_group(share::schema::ObTableSchema &table } } } - + int tmp_ret = OB_SUCCESS; + uint64_t rowkey_cg_id = ROWKEY_COLUMN_GROUP_ID; +#ifdef ERRSIM + tmp_ret = OB_E(EventTable::EN_DDL_CREATE_OLD_VERSION_COLUMN_GROUP) OB_SUCCESS; + if (OB_TMP_FAIL(tmp_ret)) { + rowkey_cg_id = table_schema.get_max_used_column_group_id() + 1; + } +#endif if (OB_FAIL(ret)) { } else if (OB_FAIL(ObSchemaUtils::build_column_group( table_schema, table_schema.get_tenant_id(),ObColumnGroupType::ROWKEY_COLUMN_GROUP, - OB_ROWKEY_COLUMN_GROUP_NAME, rowkey_ids, ROWKEY_COLUMN_GROUP_ID, new_rowkey_cg))) { + OB_ROWKEY_COLUMN_GROUP_NAME, rowkey_ids, rowkey_cg_id, new_rowkey_cg))) { LOG_WARN("fail to build rowkey column group", K(ret)); } else if (OB_FAIL(table_schema.add_column_group(new_rowkey_cg))) { LOG_WARN("fail to add rowkey column group to table_schema", K(ret)); @@ -988,7 +995,14 @@ int ObSchemaUtils::build_add_each_column_group(const share::schema::ObTableSchem for (;OB_SUCC(ret) && iter_begin != iter_end; ++iter_begin) { column_group_schema.reset(); ObColumnSchemaV2 *column = (*iter_begin); + int tmp_ret = OB_SUCCESS; uint64_t cg_id = dst_table_schema.get_next_single_column_group_id(); +#ifdef ERRSIM + tmp_ret = OB_E(EventTable::EN_DDL_CREATE_OLD_VERSION_COLUMN_GROUP) OB_SUCCESS; + if (OB_TMP_FAIL(tmp_ret)) { + cg_id = dst_table_schema.get_max_used_column_group_id() + 1; + } +#endif if (OB_ISNULL(column)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("column schema should not be null", K(ret)); @@ -1074,14 +1088,12 @@ int ObSchemaUtils::build_all_column_group( LOG_WARN("fail to push back value", K(ret)); } } - if (OB_FAIL(ret)) { } else { const ObString cg_name = OB_ALL_COLUMN_GROUP_NAME; if (column_ids.count() <= 0) { ret = OB_ERR_UNEXPECTED; LOG_WARN("number of available columns should not be zeror", K(ret)); - } else if (OB_FAIL(build_column_group(table_schema, tenant_id, ObColumnGroupType::ALL_COLUMN_GROUP, cg_name, column_ids, column_group_id, column_group_schema))) { diff --git a/src/share/schema/ob_table_param.cpp b/src/share/schema/ob_table_param.cpp index 4e71b4a8a..6ab769a8a 100644 --- a/src/share/schema/ob_table_param.cpp +++ b/src/share/schema/ob_table_param.cpp @@ -1033,7 +1033,7 @@ int ObTableParam::construct_columns_and_projector( LOG_WARN("fail to push_back tmp_access_cols_extend", K(ret)); } else if (is_cs) { if (OB_FAIL(table_schema.get_column_group_index(*column, is_column_replica_table_, cg_idx))) { - LOG_WARN("Fail to get column group index", K(ret)); + LOG_WARN("Fail to get column group index", K(ret), KPC(column)); } else if (OB_FAIL(tmp_cg_idxs.push_back(cg_idx))) { LOG_WARN("Fail to push back cg idx", K(ret)); } diff --git a/src/share/schema/ob_table_schema.cpp b/src/share/schema/ob_table_schema.cpp index ce2e1e0c0..9fd75e1c2 100644 --- a/src/share/schema/ob_table_schema.cpp +++ b/src/share/schema/ob_table_schema.cpp @@ -9838,7 +9838,7 @@ int ObTableSchema::get_column_group_index( if (OB_SUCC(ret) && !found) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("Unexpected, can not find cg idx", K(ret), K(column_id)); + LOG_WARN("Unexpected, can not find cg idx", K(ret), K(column_id), K_(max_used_column_group_id)); } } LOG_TRACE("[CS-Replica] get column group index", K(ret), K(need_calculate_cg_idx), K(param), K(cg_idx), KPC(this)); diff --git a/src/sql/resolver/ddl/ob_create_table_resolver_base.cpp b/src/sql/resolver/ddl/ob_create_table_resolver_base.cpp index 19edb843a..1f9de2d3a 100644 --- a/src/sql/resolver/ddl/ob_create_table_resolver_base.cpp +++ b/src/sql/resolver/ddl/ob_create_table_resolver_base.cpp @@ -331,12 +331,20 @@ uint64_t ObCreateTableResolverBase::gen_column_group_id() int ObCreateTableResolverBase::resolve_column_group_helper(const ParseNode *cg_node, ObTableSchema &table_schema) { + int tmp_ret = OB_SUCCESS; int ret = OB_SUCCESS; ObArray column_ids; // not include virtual column uint64_t compat_version = 0; ObTableStoreType table_store_type = OB_TABLE_STORE_INVALID; const uint64_t tenant_id = table_schema.get_tenant_id(); const int64_t column_cnt = table_schema.get_column_count(); + uint64_t all_cg_id = ALL_COLUMN_GROUP_ID; +#ifdef ERRSIM + tmp_ret = OB_E(EventTable::EN_DDL_CREATE_OLD_VERSION_COLUMN_GROUP) OB_SUCCESS; + if (OB_TMP_FAIL(tmp_ret)) { + all_cg_id = table_schema.get_max_used_column_group_id() + 1; + } +#endif if (OB_FAIL(column_ids.reserve(column_cnt))) { LOG_WARN("fail to reserve", KR(ret), K(column_cnt)); } else if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, compat_version))) { @@ -381,7 +389,7 @@ int ObCreateTableResolverBase::resolve_column_group_helper(const ParseNode *cg_n } else if (!ObSchemaUtils::can_add_column_group(table_schema)) { } else if (ObTableStoreFormat::is_row_with_column_store(table_store_type)) { if (OB_FAIL(ObSchemaUtils::build_all_column_group(table_schema, table_schema.get_tenant_id(), - ALL_COLUMN_GROUP_ID, all_cg))) { + all_cg_id, all_cg))) { LOG_WARN("fail to add all column group", K(ret)); } else if (OB_FAIL(table_schema.add_column_group(all_cg))) { LOG_WARN("fail to build all column group", K(ret)); @@ -406,8 +414,10 @@ int ObCreateTableResolverBase::resolve_column_group_helper(const ParseNode *cg_n } } - if (FAILEDx(table_schema.adjust_column_group_array())) { - LOG_WARN("fail to adjust column group array", K(ret), K(table_schema)); + if (OB_SUCC(ret) && OB_SUCCESS == tmp_ret) { + if (OB_FAIL(table_schema.adjust_column_group_array())) { + LOG_WARN("fail to adjust column group array", K(ret), K(table_schema)); + } } } return ret; diff --git a/src/storage/compaction/ob_medium_compaction_func.cpp b/src/storage/compaction/ob_medium_compaction_func.cpp index 8f4c7f25a..c4257669f 100644 --- a/src/storage/compaction/ob_medium_compaction_func.cpp +++ b/src/storage/compaction/ob_medium_compaction_func.cpp @@ -906,7 +906,7 @@ int ObMediumCompactionScheduleFunc::init_co_major_merge_type( // REBUILD_COLUMN_GROUP is requested by user or implicitly required by delayed column group transform // only use row store to build column store medium_info.co_major_merge_type_ = ObCOMajorMergePolicy::USE_RS_BUILD_SCHEMA_MATCH_MERGE; - LOG_INFO("use row store to build column store", K(ret), K(merge_reason_), K(result.handle_)); + LOG_INFO("use row store to build column store", K(ret), K(merge_reason_), K(result.handle_), KPC(first_sstable)); } else if (FALSE_IT(co_sstable = static_cast(first_sstable))) { } else if (OB_FAIL(iter.set_tablet_handle(tablet_handle_))) { LOG_WARN("failed to set tablet handle", K(ret), K(iter), K(tablet_handle_));