From e603b2fe6af99096d99f705ec1c58049d65c2d29 Mon Sep 17 00:00:00 2001 From: tino247 Date: Tue, 13 Dec 2022 13:07:55 +0000 Subject: [PATCH] [CP] Fix schema & upgrade related problems --- src/rootserver/ob_system_admin_util.cpp | 4 ++-- src/share/ob_rpc_struct.cpp | 2 +- .../schema/ob_multi_version_schema_service.cpp | 6 ++---- src/share/schema/ob_schema_mgr.cpp | 1 + src/share/schema/ob_schema_struct.h | 13 +++++++++++++ tools/upgrade/special_upgrade_action_post.py | 3 +++ tools/upgrade/upgrade_post.py | 5 ++++- tools/upgrade/upgrade_pre.py | 5 ++++- 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/rootserver/ob_system_admin_util.cpp b/src/rootserver/ob_system_admin_util.cpp index 262ca2ad1..ba6199473 100644 --- a/src/rootserver/ob_system_admin_util.cpp +++ b/src/rootserver/ob_system_admin_util.cpp @@ -1403,7 +1403,7 @@ int ObAdminUpgradeCmd::execute(const Bool &upgrade) } } if (OB_FAIL(ret)) { - } else if (admin_set_config.execute(set_config_arg)) { + } else if (OB_FAIL(admin_set_config.execute(set_config_arg))) { LOG_WARN("execute set config failed", KR(ret)); } else { LOG_INFO("change upgrade parameters", @@ -1434,7 +1434,7 @@ int ObAdminRollingUpgradeCmd::execute(const obrpc::ObAdminRollingUpgradeArg &arg LOG_WARN("assign _upgrade_stage config value failed", KR(ret), K(arg)); } else if (OB_FAIL(set_config_arg.items_.push_back(upgrade_stage_item))) { LOG_WARN("add _upgrade_stage config item failed", KR(ret), K(arg)); - } else if (admin_set_config.execute(set_config_arg)) { + } else if (OB_FAIL(admin_set_config.execute(set_config_arg))) { LOG_WARN("execute set config failed", KR(ret)); } else { LOG_INFO("change upgrade parameters", KR(ret), "_upgrade_stage", arg.stage_); diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index 4ad852ff7..e05cff596 100644 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -40,7 +40,7 @@ static const char* upgrade_stage_str[OB_UPGRADE_STAGE_MAX] = { "NONE", "PREUPGRADE", "DBUPGRADE", - "POSTUPRADE" + "POSTUPGRADE" }; const char* get_upgrade_stage_str(ObUpgradeStage stage) diff --git a/src/share/schema/ob_multi_version_schema_service.cpp b/src/share/schema/ob_multi_version_schema_service.cpp index 8493994d8..f1323cc60 100644 --- a/src/share/schema/ob_multi_version_schema_service.cpp +++ b/src/share/schema/ob_multi_version_schema_service.cpp @@ -2309,7 +2309,7 @@ int ObMultiVersionSchemaService::refresh_and_add_schema(const ObIArray // Ensure that the memory on the stack requested during the refresh schema process also uses the default 500 tenant ObArenaAllocator allocator(ObModIds::OB_MODULE_PAGE_ALLOCATOR, OB_MALLOC_BIG_BLOCK_SIZE, OB_SERVER_TENANT_ID); - schema_stack_allocator() = &allocator; + ObSchemaStackAllocatorGuard guard(&allocator); ObArray all_tenant_ids; if (OB_FAIL(ret)) { @@ -2358,7 +2358,6 @@ int ObMultiVersionSchemaService::refresh_and_add_schema(const ObIArray } } } - schema_stack_allocator() = nullptr; }; CREATE_WITH_TEMP_ENTITY_P(!ObSchemaService::g_liboblog_mode_, RESOURCE_OWNER, common::OB_SERVER_TENANT_ID) { @@ -2465,7 +2464,7 @@ int ObMultiVersionSchemaService::auto_switch_mode_and_refresh_schema( auto func = [&]() { // Ensure that the memory on the stack requested during the refresh schema process also uses the default 500 tenant ObArenaAllocator allocator(ObModIds::OB_MODULE_PAGE_ALLOCATOR, OB_MALLOC_BIG_BLOCK_SIZE, OB_SERVER_TENANT_ID); - schema_stack_allocator() = &allocator; + ObSchemaStackAllocatorGuard guard(&allocator); bool need_refresh_schema = true; // The schema needs to be refreshed by default // If the user configures expected_schema_version, first obtain the latest schema version. @@ -2568,7 +2567,6 @@ int ObMultiVersionSchemaService::auto_switch_mode_and_refresh_schema( } } } - schema_stack_allocator() = nullptr; }; if (OB_SUCCESS == ret) { diff --git a/src/share/schema/ob_schema_mgr.cpp b/src/share/schema/ob_schema_mgr.cpp index 483f49ebc..c37a146d6 100644 --- a/src/share/schema/ob_schema_mgr.cpp +++ b/src/share/schema/ob_schema_mgr.cpp @@ -3011,6 +3011,7 @@ int ObSchemaMgr::rebuild_schema_meta_if_not_consistent() } // Check whether db and table are consistent if (!check_schema_meta_consistent()) { + ret = OB_ERROR; LOG_ERROR("schema meta is still not consistent after rebuild, need fixing", K(ret)); right_to_die_or_duty_to_live(); } diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index ee8a97fd6..b6f02248e 100644 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -6651,6 +6651,19 @@ private: }; common::ObIAllocator *&schema_stack_allocator(); +class ObSchemaStackAllocatorGuard +{ +public: + ObSchemaStackAllocatorGuard() = delete; + explicit ObSchemaStackAllocatorGuard(ObIAllocator *allocator) + { + schema_stack_allocator() = allocator; + } + ~ObSchemaStackAllocatorGuard() + { + schema_stack_allocator() = NULL; + } +}; class ObLabelSePolicySchema : public ObSchema {//simple schema diff --git a/tools/upgrade/special_upgrade_action_post.py b/tools/upgrade/special_upgrade_action_post.py index 22786766e..ed308f664 100755 --- a/tools/upgrade/special_upgrade_action_post.py +++ b/tools/upgrade/special_upgrade_action_post.py @@ -198,6 +198,9 @@ def check_upgrade_job_result(cur, version, max_used_job_id): logging.warn("invalid job status: {0}".format(results[0][0])) raise e + if times >= 180: + logging.warn("run upgrade job timeout") + raise e times = times + 1 time.sleep(10) except Exception, e: diff --git a/tools/upgrade/upgrade_post.py b/tools/upgrade/upgrade_post.py index 0a1098fbd..e25ef4eb4 100755 --- a/tools/upgrade/upgrade_post.py +++ b/tools/upgrade/upgrade_post.py @@ -1242,6 +1242,9 @@ # logging.warn("invalid job status: {0}".format(results[0][0])) # raise e # +# if times >= 180: +# logging.warn("run upgrade job timeout") +# raise e # times = times + 1 # time.sleep(10) # except Exception, e: @@ -2259,7 +2262,7 @@ # #class UpgradeParams: # log_filename = 'upgrade_post_checker.log' -# new_version = '4.0.0.0' +# new_version = '4.1.0.0' ##### --------------start : my_error.py -------------- #class MyError(Exception): # def __init__(self, value): diff --git a/tools/upgrade/upgrade_pre.py b/tools/upgrade/upgrade_pre.py index f1c53e451..075b450dc 100755 --- a/tools/upgrade/upgrade_pre.py +++ b/tools/upgrade/upgrade_pre.py @@ -1242,6 +1242,9 @@ # logging.warn("invalid job status: {0}".format(results[0][0])) # raise e # +# if times >= 180: +# logging.warn("run upgrade job timeout") +# raise e # times = times + 1 # time.sleep(10) # except Exception, e: @@ -2259,7 +2262,7 @@ # #class UpgradeParams: # log_filename = 'upgrade_post_checker.log' -# new_version = '4.0.0.0' +# new_version = '4.1.0.0' ##### --------------start : my_error.py -------------- #class MyError(Exception): # def __init__(self, value):