From 76f69d933f8c74d31c186e0f63f4d2cdf78b6ae3 Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 27 Nov 2023 08:24:06 +0000 Subject: [PATCH] [BUGFIX]fix rename/drop table hashset full --- src/rootserver/ob_ddl_service.cpp | 15 +++++++++++---- src/share/schema/ob_schema_struct.h | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index bd138bf2d..4c1366caa 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -13518,12 +13518,16 @@ int ObDDLService::rename_table(const obrpc::ObRenameTableArg &rename_table_arg) } else { //todo use array to replace hashmap and hashset @hualong //record table already be renamed in the schema mgr - common::hash::ObPlacementHashSet delete_table_set; + common::hash::ObHashSet delete_table_set; //record new table name set //table_item -> table_id common::hash::ObHashMap new_table_map; ObArray> all_dep_objs; - if (OB_FAIL(new_table_map.create(32, ObModIds::OB_HASH_BUCKET_RENAME_TABLE_MAP))) { + const int64_t rename_items_count = rename_table_arg.rename_table_items_.size(); + + if (OB_FAIL(delete_table_set.create(rename_items_count))) { + LOG_WARN("failed to add create ObHashSet", KR(ret)); + } else if (OB_FAIL(new_table_map.create(rename_items_count, ObModIds::OB_HASH_BUCKET_RENAME_TABLE_MAP))) { LOG_WARN("failed to add create ObHashMap", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < rename_table_arg.rename_table_items_.size(); ++i) { @@ -19496,7 +19500,7 @@ int ObDDLService::drop_table_in_trans( if (foreign_key_info.is_parent_table_mock_) { // TODO:@xiaofeng.lby, delete this restriction, if (OB_NOT_NULL(drop_table_set)) { - if (drop_table_set->count() > 1) { + if (drop_table_set->size() > 1) { ret = OB_NOT_SUPPORTED; LOG_WARN("drop multi tables with mock fks in one sql is not supported ", K(ret)); } @@ -21170,7 +21174,10 @@ int ObDDLService::drop_table(const ObDropTableArg &drop_table_arg, const obrpc:: int64_t refreshed_schema_version = 0; ObDDLSQLTransaction trans(schema_service_); DropTableIdHashSet drop_table_set; - if (TMP_TABLE == drop_table_arg.table_type_ + const int64_t drop_table_count = drop_table_arg.tables_.count(); + if (OB_FAIL(drop_table_set.create(drop_table_count))) { + LOG_WARN("fail to add create ObHashSet", KR(ret)); + } else if (TMP_TABLE == drop_table_arg.table_type_ || TMP_TABLE_ORA_TRX == drop_table_arg.table_type_ || TMP_TABLE_ORA_SESS == drop_table_arg.table_type_ || TMP_TABLE_ALL == drop_table_arg.table_type_) { diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index 05e51c32d..affeb2825 100755 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -6114,7 +6114,7 @@ inline bool ObRecycleObject::is_valid() const return INVALID != type_ && !object_name_.empty() && !original_name_.empty(); } -typedef common::hash::ObPlacementHashSet DropTableIdHashSet; +typedef common::hash::ObHashSet DropTableIdHashSet; // Used to count vertical partition columns typedef common::hash::ObPlacementHashSet VPColumnNameHashSet;