From d29f6ff8a44411a57cf0b167407341451a8e232a Mon Sep 17 00:00:00 2001 From: ChangerR Date: Fri, 19 Jan 2024 05:12:31 +0000 Subject: [PATCH] [CP] [CP] add max_partition_num config in mysql mode --- src/rootserver/ob_ddl_service.cpp | 8 ++++++-- src/share/parameter/ob_parameter_seed.ipp | 3 +++ src/sql/resolver/ddl/ob_ddl_resolver.cpp | 6 ++++-- src/sql/resolver/ddl/ob_tablegroup_resolver.cpp | 17 +++++++++++------ src/sql/resolver/ob_resolver_utils.cpp | 10 ++++++++++ src/sql/resolver/ob_resolver_utils.h | 2 ++ .../mysql/all_virtual_sys_parameter_stat.result | 1 + 7 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index 1805b34dc8..cf6ecffa4f 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -14521,7 +14521,9 @@ int ObDDLService::check_alter_add_partitions(const share::schema::ObTableSchema ret = OB_ERR_ONLY_ON_RANGE_LIST_PARTITION; LOG_WARN("add partition can only be used on RANGE/LIST partitions", K(ret), K(alter_table_arg)); } else if ((is_oracle_mode && OB_MAX_PARTITION_NUM_ORACLE < orig_table_schema.get_all_part_num() + inc_part_num) - || (!is_oracle_mode && OB_MAX_PARTITION_NUM_MYSQL < orig_table_schema.get_all_part_num() + inc_part_num)) { + || (!is_oracle_mode + && ObResolverUtils::get_mysql_max_partition_num(orig_table_schema.get_tenant_id()) + < orig_table_schema.get_all_part_num() + inc_part_num)) { ret = OB_TOO_MANY_PARTITIONS_ERROR; LOG_WARN("too many partitions", K(ret), "partition cnt current", orig_table_schema.get_all_part_num(), @@ -14650,7 +14652,9 @@ int ObDDLService::check_alter_add_subpartitions(const share::schema::ObTableSche ret = OB_ERR_ONLY_ON_RANGE_LIST_PARTITION; LOG_WARN("add partition can only be used on RANGE/LIST partitions", K(ret), K(alter_table_arg)); } else if ((is_oracle_mode && OB_MAX_PARTITION_NUM_ORACLE < orig_table_schema.get_all_part_num() + part_num) - || (!is_oracle_mode && OB_MAX_PARTITION_NUM_MYSQL < orig_table_schema.get_all_part_num() + part_num)) { + || (!is_oracle_mode + && ObResolverUtils::get_mysql_max_partition_num(orig_table_schema.get_tenant_id()) + < orig_table_schema.get_all_part_num() + part_num)) { ret = OB_TOO_MANY_PARTITIONS_ERROR; LOG_WARN("too many partitions", K(ret), "partition cnt current", orig_table_schema.get_all_part_num(), diff --git a/src/share/parameter/ob_parameter_seed.ipp b/src/share/parameter/ob_parameter_seed.ipp index 848ba03dca..aed152c50a 100644 --- a/src/share/parameter/ob_parameter_seed.ipp +++ b/src/share/parameter/ob_parameter_seed.ipp @@ -1846,3 +1846,6 @@ DEF_BOOL(enable_rpc_authentication_bypass, OB_CLUSTER_PARAMETER, "True", // DEF_INT(_checkpoint_diagnose_preservation_count, OB_TENANT_PARAMETER, "100", "[0,1000]", // "the count of checkpoint diagnose info preservation", // ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); +DEF_INT(max_partition_num, OB_TENANT_PARAMETER, "8192", "[8192, 65536]", + "set max partition num in mysql mode", + ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); diff --git a/src/sql/resolver/ddl/ob_ddl_resolver.cpp b/src/sql/resolver/ddl/ob_ddl_resolver.cpp index 695d908212..c1e4a15d41 100644 --- a/src/sql/resolver/ddl/ob_ddl_resolver.cpp +++ b/src/sql/resolver/ddl/ob_ddl_resolver.cpp @@ -9257,7 +9257,8 @@ int ObDDLResolver::resolve_partition_node(ObPartitionedStmt *stmt, partnum = table_schema.get_all_part_num(); } if (partnum > (lib::is_oracle_mode() - ? common::OB_MAX_PARTITION_NUM_ORACLE : common::OB_MAX_PARTITION_NUM_MYSQL)) { + ? common::OB_MAX_PARTITION_NUM_ORACLE : + ObResolverUtils::get_mysql_max_partition_num(table_schema.get_tenant_id()))) { ret = common::OB_TOO_MANY_PARTITIONS_ERROR; } } @@ -9572,7 +9573,8 @@ int ObDDLResolver::resolve_partition_hash_or_key( LOG_USER_ERROR(OB_NO_PARTS_ERROR); } else if (!common::is_virtual_table(table_id_) && partition_num > (lib::is_oracle_mode() - ? common::OB_MAX_PARTITION_NUM_ORACLE : common::OB_MAX_PARTITION_NUM_MYSQL)) { + ? common::OB_MAX_PARTITION_NUM_ORACLE + : sql::ObResolverUtils::get_mysql_max_partition_num(table_schema.get_tenant_id()))) { ret = common::OB_TOO_MANY_PARTITIONS_ERROR; } else if (is_subpartition) { if (NULL != node->children_[HASH_PARTITION_LIST_NODE]) { diff --git a/src/sql/resolver/ddl/ob_tablegroup_resolver.cpp b/src/sql/resolver/ddl/ob_tablegroup_resolver.cpp index 5ed9f27823..78e6bc72bc 100644 --- a/src/sql/resolver/ddl/ob_tablegroup_resolver.cpp +++ b/src/sql/resolver/ddl/ob_tablegroup_resolver.cpp @@ -17,6 +17,7 @@ #include "sql/resolver/ddl/ob_ddl_resolver.h" #include "sql/resolver/ddl/ob_create_tablegroup_stmt.h" #include "sql/parser/parse_node.h" +#include "sql/resolver/ob_resolver_utils.h" namespace oceanbase { @@ -58,9 +59,9 @@ int ObTableGroupResolver::resolve_partition_hash_or_key(ObTablegroupStmt *stmt, ObPartitionFuncType partition_func_type = PARTITION_FUNC_TYPE_HASH; int64_t partition_num = 0; ObPartitionOption *partition_option = NULL; - if (OB_ISNULL(stmt) || OB_ISNULL(node)) { + if (OB_ISNULL(stmt) || OB_ISNULL(node) || OB_ISNULL(session_info_)) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid arguemnt", K(ret), K(stmt), K(node)); + LOG_WARN("invalid arguemnt", K(ret), K(stmt), K(node), K(session_info_)); } else { if (is_subpartition) { partition_option = &(tablegroup_schema.get_sub_part_option()); @@ -140,7 +141,8 @@ int ObTableGroupResolver::resolve_partition_hash_or_key(ObTablegroupStmt *stmt, } if (OB_SUCC(ret)) { if (tablegroup_schema.get_all_part_num() > (lib::is_oracle_mode() - ? OB_MAX_PARTITION_NUM_ORACLE : OB_MAX_PARTITION_NUM_MYSQL)) { + ? OB_MAX_PARTITION_NUM_ORACLE + : ObResolverUtils::get_mysql_max_partition_num(session_info_->get_effective_tenant_id()))) { ret = OB_TOO_MANY_PARTITIONS_ERROR; } } @@ -160,7 +162,8 @@ int ObTableGroupResolver::resolve_partition_range(ObTablegroupStmt *tablegroup_s { int ret = OB_SUCCESS; PartitionInfo part_info; - if (OB_ISNULL(tablegroup_stmt) || OB_ISNULL(node)) { + if (OB_ISNULL(tablegroup_stmt) || OB_ISNULL(node) || + OB_ISNULL(session_info_)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(tablegroup_stmt), K(node)); } else if (OB_FAIL(resolve_partition_range(tablegroup_stmt, node, is_subpartition, tablegroup_schema, part_info))) { @@ -198,7 +201,8 @@ int ObTableGroupResolver::resolve_partition_range(ObTablegroupStmt *tablegroup_s } if (OB_SUCC(ret)) { if (tablegroup_schema.get_all_part_num() > (lib::is_oracle_mode() - ? OB_MAX_PARTITION_NUM_ORACLE : OB_MAX_PARTITION_NUM_MYSQL)) { + ? OB_MAX_PARTITION_NUM_ORACLE + : sql::ObResolverUtils::get_mysql_max_partition_num(session_info_->get_effective_tenant_id()))) { ret = OB_TOO_MANY_PARTITIONS_ERROR; } } @@ -363,7 +367,8 @@ int ObTableGroupResolver::resolve_partition_list(ObTablegroupStmt *stmt, } if (OB_SUCC(ret)) { if (tablegroup_schema.get_all_part_num() > (lib::is_oracle_mode() - ? OB_MAX_PARTITION_NUM_ORACLE : OB_MAX_PARTITION_NUM_MYSQL)) { + ? OB_MAX_PARTITION_NUM_ORACLE + : sql::ObResolverUtils::get_mysql_max_partition_num(session_info_->get_effective_tenant_id()))) { ret = OB_TOO_MANY_PARTITIONS_ERROR; } } diff --git a/src/sql/resolver/ob_resolver_utils.cpp b/src/sql/resolver/ob_resolver_utils.cpp index 3dc7b82eac..676d6ed59b 100644 --- a/src/sql/resolver/ob_resolver_utils.cpp +++ b/src/sql/resolver/ob_resolver_utils.cpp @@ -8612,5 +8612,15 @@ int ObResolverUtils::check_allowed_alter_operations_for_mlog( return ret; } +int64_t ObResolverUtils::get_mysql_max_partition_num(const uint64_t tenant_id) +{ + int64_t max_partition_num = OB_MAX_PARTITION_NUM_MYSQL; + omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id)); + if (tenant_config.is_valid()) { + max_partition_num = tenant_config->max_partition_num; + } + return max_partition_num; +} + } // namespace sql } // namespace oceanbase diff --git a/src/sql/resolver/ob_resolver_utils.h b/src/sql/resolver/ob_resolver_utils.h index c80a3f71b5..3aa0a95ccd 100644 --- a/src/sql/resolver/ob_resolver_utils.h +++ b/src/sql/resolver/ob_resolver_utils.h @@ -787,6 +787,8 @@ public: const uint64_t tenant_id, const obrpc::ObAlterTableArg &arg, const share::schema::ObTableSchema &table_schema); + + static int64_t get_mysql_max_partition_num(const uint64_t tenant_id); private: static int try_convert_to_unsiged(const ObExprResType restype, ObRawExpr& src_expr, diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result index fe4a58f080..53c2d52f4e 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result @@ -143,6 +143,7 @@ ls_gc_delay_time ls_meta_table_check_interval major_compact_trigger major_freeze_duty_time +max_partition_num max_stale_time_for_weak_consistency max_string_print_length max_syslog_file_count