fix wrong cpu_capacity in __all_virtual_server after cpu_count changing
This commit is contained in:
		| @ -547,7 +547,7 @@ int MockTenantModuleEnv::init_before_start_mtl() | |||||||
|   const int64_t ts_ns = ObTimeUtility::current_time_ns(); |   const int64_t ts_ns = ObTimeUtility::current_time_ns(); | ||||||
|   env_dir_ = "./env_" + std::to_string(rpc_port_) + "_" + std::to_string(ts_ns); |   env_dir_ = "./env_" + std::to_string(rpc_port_) + "_" + std::to_string(ts_ns); | ||||||
|   run_dir_ = "./run_" + std::to_string(rpc_port_) + "_" + std::to_string(ts_ns); |   run_dir_ = "./run_" + std::to_string(rpc_port_) + "_" + std::to_string(ts_ns); | ||||||
|  |   GCONF.cpu_count = 2; | ||||||
|   uint64_t start_time = 10000000; |   uint64_t start_time = 10000000; | ||||||
|   scramble_rand_.init(static_cast<uint64_t>(start_time), static_cast<uint64_t>(start_time / 2)); |   scramble_rand_.init(static_cast<uint64_t>(start_time), static_cast<uint64_t>(start_time / 2)); | ||||||
|   if (OB_FAIL(init_dir())) { |   if (OB_FAIL(init_dir())) { | ||||||
| @ -581,7 +581,7 @@ int MockTenantModuleEnv::init_before_start_mtl() | |||||||
|     STORAGE_LOG(WARN, "fail to init env", K(ret)); |     STORAGE_LOG(WARN, "fail to init env", K(ret)); | ||||||
|   } else if (OB_FAIL(ObServerCheckpointSlogHandler::get_instance().init())) { |   } else if (OB_FAIL(ObServerCheckpointSlogHandler::get_instance().init())) { | ||||||
|     STORAGE_LOG(ERROR, "init server checkpoint slog handler fail", K(ret)); |     STORAGE_LOG(ERROR, "init server checkpoint slog handler fail", K(ret)); | ||||||
|   } else if (OB_FAIL(multi_tenant_.init(self_addr_, 2, 2, nullptr, false))) { |   } else if (OB_FAIL(multi_tenant_.init(self_addr_, nullptr, false))) { | ||||||
|     STORAGE_LOG(WARN, "fail to init env", K(ret)); |     STORAGE_LOG(WARN, "fail to init env", K(ret)); | ||||||
|   } else if (OB_FAIL(sql_engine_.get_plan_cache_manager()->get_plan_cache_map().create(hash::cal_next_prime(512), |   } else if (OB_FAIL(sql_engine_.get_plan_cache_manager()->get_plan_cache_map().create(hash::cal_next_prime(512), | ||||||
|                             ObModIds::OB_HASH_BUCKET_PLAN_CACHE, |                             ObModIds::OB_HASH_BUCKET_PLAN_CACHE, | ||||||
|  | |||||||
| @ -102,8 +102,7 @@ int ObHeartBeatProcess::init_lease_request(ObLeaseRequest &lease_request) | |||||||
|     lease_request.zone_ = gctx_.config_->zone.str(); |     lease_request.zone_ = gctx_.config_->zone.str(); | ||||||
|     lease_request.server_ = gctx_.self_addr(); |     lease_request.server_ = gctx_.self_addr(); | ||||||
|     lease_request.sql_port_ = gctx_.config_->mysql_port; |     lease_request.sql_port_ = gctx_.config_->mysql_port; | ||||||
|     lease_request.resource_info_.cpu_ |     lease_request.resource_info_.cpu_ = get_cpu_count(); | ||||||
|         = gctx_.omt_->get_node_quota(); |  | ||||||
|     lease_request.resource_info_.report_cpu_assigned_ = svr_res_assigned.min_cpu_; |     lease_request.resource_info_.report_cpu_assigned_ = svr_res_assigned.min_cpu_; | ||||||
|     lease_request.resource_info_.report_cpu_max_assigned_ = svr_res_assigned.max_cpu_; |     lease_request.resource_info_.report_cpu_max_assigned_ = svr_res_assigned.max_cpu_; | ||||||
|     lease_request.resource_info_.report_mem_assigned_ = svr_res_assigned.memory_size_; |     lease_request.resource_info_.report_mem_assigned_ = svr_res_assigned.memory_size_; | ||||||
|  | |||||||
| @ -1728,24 +1728,7 @@ int ObServer::init_multi_tenant() | |||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|  |  | ||||||
|   // get node cpu count from sysconf if node_cpu_count config isn't |  | ||||||
|   // specified. |  | ||||||
|   int64_t node_cpu_count = get_cpu_num(); |  | ||||||
|   if (GCONF.cpu_count > "0") { |  | ||||||
|     node_cpu_count = GCONF.cpu_count; |  | ||||||
|     LOG_INFO("calc NODE CPU COUNT using config(node_cpu_count) for test", |  | ||||||
|              K(node_cpu_count)); |  | ||||||
|   } else { |  | ||||||
|     LOG_INFO("calc NODE CPU COUNT using sysconf function", |  | ||||||
|              K(node_cpu_count)); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   const int64_t cpu_count = node_cpu_count; |  | ||||||
|   const int64_t times_of_workers = GCONF.workers_per_cpu_quota; |  | ||||||
|  |  | ||||||
|   if (OB_FAIL(multi_tenant_.init(self_addr_, |   if (OB_FAIL(multi_tenant_.init(self_addr_, | ||||||
|                                  static_cast<double>(cpu_count), |  | ||||||
|                                  times_of_workers, |  | ||||||
|                                  &sql_proxy_))) { |                                  &sql_proxy_))) { | ||||||
|     LOG_ERROR("init multi tenant fail", KR(ret)); |     LOG_ERROR("init multi tenant fail", KR(ret)); | ||||||
|  |  | ||||||
|  | |||||||
| @ -246,10 +246,6 @@ int ObServerReloadConfig::operator()() | |||||||
|   share::ObTaskController::get().set_log_rate_limit( |   share::ObTaskController::get().set_log_rate_limit( | ||||||
|       GCONF.syslog_io_bandwidth_limit.get_value()); |       GCONF.syslog_io_bandwidth_limit.get_value()); | ||||||
|  |  | ||||||
|   if (nullptr != GCTX.omt_) { |  | ||||||
|     GCTX.omt_->set_workers_per_cpu(GCONF.workers_per_cpu_quota.get_value()); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   get_unis_global_compat_version() = GET_MIN_CLUSTER_VERSION(); |   get_unis_global_compat_version() = GET_MIN_CLUSTER_VERSION(); | ||||||
|   lib::g_runtime_enabled = true; |   lib::g_runtime_enabled = true; | ||||||
|  |  | ||||||
|  | |||||||
| @ -208,14 +208,11 @@ ObMultiTenant::ObMultiTenant() | |||||||
|       bucket_lock_(), |       bucket_lock_(), | ||||||
|       lock_(ObLatchIds::MULTI_TENANT_LOCK), |       lock_(ObLatchIds::MULTI_TENANT_LOCK), | ||||||
|       tenants_(0, nullptr, ObModIds::OMT), |       tenants_(0, nullptr, ObModIds::OMT), | ||||||
|       node_quota_(0), |  | ||||||
|       times_of_workers_(0), |  | ||||||
|       balancer_(nullptr), |       balancer_(nullptr), | ||||||
|       myaddr_(), |       myaddr_(), | ||||||
|       cpu_dump_(false), |       cpu_dump_(false), | ||||||
|       has_synced_(false) |       has_synced_(false) | ||||||
| { | { | ||||||
|   node_quota_ = DEFAULT_NODE_QUOTA; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static int init_compat_mode(lib::Worker::CompatMode &compat_mode) | static int init_compat_mode(lib::Worker::CompatMode &compat_mode) | ||||||
| @ -239,8 +236,6 @@ static int init_compat_mode(lib::Worker::CompatMode &compat_mode) | |||||||
| } | } | ||||||
|  |  | ||||||
| int ObMultiTenant::init(ObAddr myaddr, | int ObMultiTenant::init(ObAddr myaddr, | ||||||
|                         double node_quota, |  | ||||||
|                         int64_t times_of_workers, |  | ||||||
|                         ObMySQLProxy *sql_proxy, |                         ObMySQLProxy *sql_proxy, | ||||||
|                         bool mtl_bind_flag) |                         bool mtl_bind_flag) | ||||||
| { | { | ||||||
| @ -251,16 +246,10 @@ int ObMultiTenant::init(ObAddr myaddr, | |||||||
|     LOG_WARN("ObMultiTenant has been inited", K(ret)); |     LOG_WARN("ObMultiTenant has been inited", K(ret)); | ||||||
|   } else if (OB_FAIL(SLOGGERMGR.get_server_slogger(server_slogger_))) { |   } else if (OB_FAIL(SLOGGERMGR.get_server_slogger(server_slogger_))) { | ||||||
|     LOG_WARN("fail to get server slogger", K(ret)); |     LOG_WARN("fail to get server slogger", K(ret)); | ||||||
|   } else if (node_quota <= 1 || times_of_workers < 1) { |  | ||||||
|     ret = OB_INVALID_ARGUMENT; |  | ||||||
|     LOG_ERROR("node quota should greater than 1 and times of workers should greater than or equal to 1", |  | ||||||
|       K(ret), K(node_quota), K(times_of_workers), K(ret)); |  | ||||||
|   } else if (OB_FAIL(bucket_lock_.init(OB_TENANT_LOCK_BUCKET_NUM))) { |   } else if (OB_FAIL(bucket_lock_.init(OB_TENANT_LOCK_BUCKET_NUM))) { | ||||||
|     LOG_WARN("fail to init bucket lock", K(ret)); |     LOG_WARN("fail to init bucket lock", K(ret)); | ||||||
|   } else { |   } else { | ||||||
|     myaddr_ = myaddr; |     myaddr_ = myaddr; | ||||||
|     node_quota_ = node_quota; |  | ||||||
|     times_of_workers_ = times_of_workers; |  | ||||||
|     if (NULL != sql_proxy) { |     if (NULL != sql_proxy) { | ||||||
|       if (OB_FAIL(ObTenantNodeBalancer::get_instance().init(this, *sql_proxy, myaddr))) { |       if (OB_FAIL(ObTenantNodeBalancer::get_instance().init(this, *sql_proxy, myaddr))) { | ||||||
|  |  | ||||||
| @ -713,7 +702,7 @@ int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog, cons | |||||||
|     ret = OB_NOT_INIT; |     ret = OB_NOT_INIT; | ||||||
|     LOG_WARN("group ctrl not init", K(ret)); |     LOG_WARN("group ctrl not init", K(ret)); | ||||||
|   } else if (OB_ISNULL(tenant = OB_NEW( |   } else if (OB_ISNULL(tenant = OB_NEW( | ||||||
|     ObTenant, ObModIds::OMT, tenant_id, times_of_workers_, *GCTX.cgroup_ctrl_))) { |     ObTenant, ObModIds::OMT, tenant_id, GCONF.workers_per_cpu_quota.get_value(), *GCTX.cgroup_ctrl_))) { | ||||||
|     ret = OB_ALLOCATE_MEMORY_FAILED; |     ret = OB_ALLOCATE_MEMORY_FAILED; | ||||||
|     LOG_WARN("new tenant fail", K(ret)); |     LOG_WARN("new tenant fail", K(ret)); | ||||||
|   } else if (FALSE_IT(create_step = ObTenantCreateStep::STEP_TENANT_NEWED)) { //step2 |   } else if (FALSE_IT(create_step = ObTenantCreateStep::STEP_TENANT_NEWED)) { //step2 | ||||||
| @ -1901,11 +1890,6 @@ int ObMultiTenant::get_tenant_cpu( | |||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| void ObMultiTenant::set_workers_per_cpu(int64_t v) |  | ||||||
| { |  | ||||||
|   times_of_workers_ = v; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void ObMultiTenant::set_group_sug_token() | void ObMultiTenant::set_group_sug_token() | ||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|  | |||||||
| @ -80,16 +80,12 @@ class ObMultiTenant | |||||||
|     : public share::ObThreadPool |     : public share::ObThreadPool | ||||||
| { | { | ||||||
| public: | public: | ||||||
|   const     static int64_t DEFAULT_TIMES_OF_WORKERS = 10; |  | ||||||
|   const     static int64_t TIME_SLICE_PERIOD        = 10000; |   const     static int64_t TIME_SLICE_PERIOD        = 10000; | ||||||
|   constexpr static double  DEFAULT_NODE_QUOTA       = 16.; |  | ||||||
|  |  | ||||||
| public: | public: | ||||||
|   explicit ObMultiTenant(); |   explicit ObMultiTenant(); | ||||||
|  |  | ||||||
|   int init(common::ObAddr myaddr, |   int init(common::ObAddr myaddr, | ||||||
|            double node_quota = DEFAULT_NODE_QUOTA, |  | ||||||
|            int64_t times_of_workers = DEFAULT_TIMES_OF_WORKERS, |  | ||||||
|            common::ObMySQLProxy *sql_proxy = NULL, |            common::ObMySQLProxy *sql_proxy = NULL, | ||||||
|            bool mtl_bind_flag = true); |            bool mtl_bind_flag = true); | ||||||
|  |  | ||||||
| @ -204,8 +200,6 @@ protected: | |||||||
|  |  | ||||||
|   mutable common::SpinRWLock lock_; // protect tenant list |   mutable common::SpinRWLock lock_; // protect tenant list | ||||||
|   TenantList tenants_; |   TenantList tenants_; | ||||||
|   double node_quota_; |  | ||||||
|   int64_t times_of_workers_; |  | ||||||
|   ObTenantNodeBalancer *balancer_; |   ObTenantNodeBalancer *balancer_; | ||||||
|   common::ObAddr myaddr_; |   common::ObAddr myaddr_; | ||||||
|   bool cpu_dump_; |   bool cpu_dump_; | ||||||
| @ -222,16 +216,6 @@ TenantList &ObMultiTenant::get_tenant_list() | |||||||
|   return tenants_; |   return tenants_; | ||||||
| } | } | ||||||
|  |  | ||||||
| double ObMultiTenant::get_node_quota() const |  | ||||||
| { |  | ||||||
|   return node_quota_; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int64_t ObMultiTenant::get_times_of_workers() const |  | ||||||
| { |  | ||||||
|   return times_of_workers_; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int ObMultiTenant::lock_tenant_list(bool write) | int ObMultiTenant::lock_tenant_list(bool write) | ||||||
| { | { | ||||||
|   int ret = common::OB_SUCCESS; |   int ret = common::OB_SUCCESS; | ||||||
|  | |||||||
| @ -79,7 +79,7 @@ int ObAllVirtualServer::inner_get_next_row(ObNewRow *&row) | |||||||
|   } else { |   } else { | ||||||
|     const int64_t col_count = output_column_ids_.count(); |     const int64_t col_count = output_column_ids_.count(); | ||||||
|     const double hard_limit = GCONF.resource_hard_limit; |     const double hard_limit = GCONF.resource_hard_limit; | ||||||
|     const int64_t cpu_capacity = GCTX.omt_->get_node_quota(); |     const int64_t cpu_capacity = get_cpu_count(); | ||||||
|     const double cpu_capacity_max = (cpu_capacity * hard_limit) / 100; |     const double cpu_capacity_max = (cpu_capacity * hard_limit) / 100; | ||||||
|     const double cpu_assigned = svr_res_assigned.min_cpu_; |     const double cpu_assigned = svr_res_assigned.min_cpu_; | ||||||
|     const double cpu_assigned_max = svr_res_assigned.max_cpu_; |     const double cpu_assigned_max = svr_res_assigned.max_cpu_; | ||||||
|  | |||||||
| @ -60,7 +60,8 @@ TestBlockManager::TestBlockManager() | |||||||
| int TestBlockManager::init_multi_tenant() | int TestBlockManager::init_multi_tenant() | ||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|   if (OB_SUCCESS != (ret = multi_tenant_.init(addr_, 6))) { |   GCONF.cpu_count = 6; | ||||||
|  |   if (OB_SUCCESS != (ret = multi_tenant_.init(addr_))) { | ||||||
|     STORAGE_LOG(WARN, "init multi_tenant failed", K(ret)); |     STORAGE_LOG(WARN, "init multi_tenant failed", K(ret)); | ||||||
|   } else { |   } else { | ||||||
|     multi_tenant_.start(); |     multi_tenant_.start(); | ||||||
|  | |||||||
| @ -242,8 +242,9 @@ int MockObServer::init(const char *schema_file, | |||||||
| int MockObServer::init_multi_tenant() | int MockObServer::init_multi_tenant() | ||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|  |   GCONF.cpu_count = 6; | ||||||
|  |  | ||||||
|   if (OB_SUCCESS != (ret = multi_tenant_.init(self_addr_, 6))) { |   if (OB_SUCCESS != (ret = multi_tenant_.init(self_addr_))) { | ||||||
|     STORAGE_LOG(WARN, "init multi_tenant failed", K(ret)); |     STORAGE_LOG(WARN, "init multi_tenant failed", K(ret)); | ||||||
|   } else if (OB_SUCCESS != (ret = multi_tenant_.create_tenant_without_unit(OB_SYS_TENANT_ID, 3, 3))) { |   } else if (OB_SUCCESS != (ret = multi_tenant_.create_tenant_without_unit(OB_SYS_TENANT_ID, 3, 3))) { | ||||||
|     STORAGE_LOG(WARN, "add sys tenant failed", K(ret)); |     STORAGE_LOG(WARN, "add sys tenant failed", K(ret)); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 nroskill
					nroskill