From f1434905aac12ee0ff37606283f148f7511f9b76 Mon Sep 17 00:00:00 2001 From: "18523270951@163.com" <18523270951@163.com> Date: Mon, 20 Nov 2023 09:19:25 +0000 Subject: [PATCH] [CP] fix circular dependencies lead to inconsistent schema status --- src/share/schema/ob_dependency_info.cpp | 13 +++++++++++-- src/share/schema/ob_dependency_info.h | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/share/schema/ob_dependency_info.cpp b/src/share/schema/ob_dependency_info.cpp index 12e01fcd43..40ae56e535 100644 --- a/src/share/schema/ob_dependency_info.cpp +++ b/src/share/schema/ob_dependency_info.cpp @@ -404,6 +404,15 @@ int ObDependencyInfo::collect_all_dep_objs(uint64_t tenant_id, uint64_t ref_obj_id, common::ObISQLClient &sql_proxy, common::ObIArray> &objs) +{ + return collect_all_dep_objs_inner(tenant_id, ref_obj_id, ref_obj_id, sql_proxy, objs); +} + +int ObDependencyInfo::collect_all_dep_objs_inner(uint64_t tenant_id, + uint64_t root_obj_id, + uint64_t ref_obj_id, + common::ObISQLClient &sql_proxy, + common::ObIArray> &objs) { int ret = OB_SUCCESS; ObSqlString sql; @@ -433,7 +442,7 @@ int ObDependencyInfo::collect_all_dep_objs(uint64_t tenant_id, || tmp_type >= static_cast (share::schema::ObObjectType::MAX_TYPE)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get wrong obj type", K(ret)); - } else if (ref_obj_id == tmp_obj_id) { + } else if (ref_obj_id == tmp_obj_id || root_obj_id == tmp_obj_id) { // skip } else if (has_exist_in_array(objs, {static_cast (tmp_obj_id), static_cast (tmp_type)})) { // dedpulicate @@ -459,7 +468,7 @@ int ObDependencyInfo::collect_all_dep_objs(uint64_t tenant_id, LOG_WARN("too deep recusive", K(ret)); } else { for (int64_t i = init_count; OB_SUCC(ret) && i < objs.count(); ++i) { - if (OB_FAIL(collect_all_dep_objs(tenant_id, objs.at(i).first, sql_proxy, objs))) { + if (OB_FAIL(collect_all_dep_objs_inner(tenant_id, root_obj_id, objs.at(i).first, sql_proxy, objs))) { LOG_WARN("failed to collect all dep objs", K(ret), K(objs.count()), K(init_count), K(i)); } } diff --git a/src/share/schema/ob_dependency_info.h b/src/share/schema/ob_dependency_info.h index a949c06604..4fb392b4be 100644 --- a/src/share/schema/ob_dependency_info.h +++ b/src/share/schema/ob_dependency_info.h @@ -153,6 +153,11 @@ public: uint64_t ref_obj_id, common::ObISQLClient &sql_proxy, common::ObIArray> &objs); + static int collect_all_dep_objs_inner(uint64_t tenant_id, + uint64_t root_obj_id, + uint64_t ref_obj_id, + common::ObISQLClient &sql_proxy, + common::ObIArray> &objs); static int cascading_modify_obj_status(common::ObMySQLTransaction &trans, uint64_t tenant_id, uint64_t obj_id,