diff --git a/src/sql/das/ob_das_context.cpp b/src/sql/das/ob_das_context.cpp index 5700d99ddb..b19f38abf9 100644 --- a/src/sql/das/ob_das_context.cpp +++ b/src/sql/das/ob_das_context.cpp @@ -335,7 +335,8 @@ OB_INLINE int ObDASCtx::build_related_tablet_loc(ObDASTabletLoc &tablet_loc) } else if (OB_ISNULL(rv = related_tablet_map_.get_related_tablet_id(tablet_loc.tablet_id_, related_table_id))) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("get related tablet id failed", K(ret), K(tablet_loc.tablet_id_), K(related_table_id)); + LOG_WARN("get related tablet id failed", K(ret), + K(tablet_loc.tablet_id_), K(related_table_id), K(related_tablet_map_)); } } if (OB_SUCC(ret)) { diff --git a/src/sql/das/ob_das_location_router.cpp b/src/sql/das/ob_das_location_router.cpp index 040d9a09b9..2f353da31b 100644 --- a/src/sql/das/ob_das_location_router.cpp +++ b/src/sql/das/ob_das_location_router.cpp @@ -741,6 +741,7 @@ int ObDASTabletMapper::get_partition_id_map(ObObjectID partition_id, ObDASLocationRouter::ObDASLocationRouter(ObIAllocator &allocator) : last_errno_(OB_SUCCESS), + cur_errno_(OB_SUCCESS), retry_cnt_(0), all_tablet_list_(allocator), virtual_server_list_(allocator), @@ -748,6 +749,13 @@ ObDASLocationRouter::ObDASLocationRouter(ObIAllocator &allocator) { } +ObDASLocationRouter::~ObDASLocationRouter() +{ + //try to refresh location when location exception occurred + refresh_location_cache(true, cur_errno_); + cur_errno_ = OB_SUCCESS; +} + int ObDASLocationRouter::nonblock_get_readable_replica(const uint64_t tenant_id, const ObTabletID &tablet_id, ObDASTabletLoc &tablet_loc) @@ -755,14 +763,30 @@ int ObDASLocationRouter::nonblock_get_readable_replica(const uint64_t tenant_id, int ret = OB_SUCCESS; ObLSLocation ls_loc; tablet_loc.tablet_id_ = tablet_id; - if (OB_FAIL(GCTX.location_service_->nonblock_get(tenant_id, tablet_id, tablet_loc.ls_id_))) { - LOG_WARN("nonblock get ls id failed", K(ret)); + if (OB_FAIL(all_tablet_list_.push_back(tablet_id))) { + LOG_WARN("store access tablet id failed", K(ret)); + } else if (OB_FAIL(GCTX.location_service_->nonblock_get(tenant_id, + tablet_id, + tablet_loc.ls_id_))) { + LOG_WARN("nonblock get ls id failed", K(ret), K(tenant_id), K(tablet_id)); } else if (OB_FAIL(GCTX.location_service_->nonblock_get(GCONF.cluster_id, tenant_id, tablet_loc.ls_id_, ls_loc))) { LOG_WARN("get ls replica location failed", K(ret), K(tablet_loc)); } + if (is_partition_change_error(ret) && OB_SUCCESS == last_errno_ && retry_cnt_ <= 0) { + /*During the execution phase, if nonblock location interface is used to obtain the location + * and an exception occurs, retries are necessary. + * However, statement-level retries cannot rollback many execution states, + * so it is necessary to avoid retries in this scenario as much as possible. + * During the execution phase, when encountering a location exception for the first time, + * try to refresh the location once synchronously. + * If it fails, then proceed with statement-level retries.*/ + if (OB_FAIL(block_renew_tablet_location(tablet_id, ls_loc))) { + LOG_WARN("block renew tablet location failed", K(ret), K(tablet_id)); + } + } ObBLKey bl_key; bool in_black_list = true; ObSEArray remote_replicas; @@ -795,6 +819,7 @@ int ObDASLocationRouter::nonblock_get_readable_replica(const uint64_t tenant_id, tablet_loc.server_ = remote_loc->get_server(); } } + save_cur_exec_status(ret); return ret; } @@ -820,7 +845,7 @@ int ObDASLocationRouter::nonblock_get(const ObDASTableLocMeta &loc_meta, } else { ObLSID ls_id; if (OB_FAIL(all_tablet_list_.push_back(tablet_id))) { - LOG_WARN("store all tablet list failed", K(ret)); + LOG_WARN("store all tablet list failed", K(ret), K(tablet_id)); } else if (OB_FAIL(GCTX.location_service_->nonblock_get(tenant_id, tablet_id, ls_id))) { LOG_WARN("nonblock get ls id failed", K(ret)); } else if (OB_FAIL(GCTX.location_service_->nonblock_get(GCONF.cluster_id, @@ -829,7 +854,20 @@ int ObDASLocationRouter::nonblock_get(const ObDASTableLocMeta &loc_meta, location))) { LOG_WARN("fail to get tablet locations", K(ret), K(tenant_id), K(ls_id)); } + if (is_partition_change_error(ret) && OB_SUCCESS == last_errno_ && retry_cnt_ <= 0) { + /*During the execution phase, if nonblock location interface is used to obtain the location + * and an exception occurs, retries are necessary. + * However, statement-level retries cannot rollback many execution states, + * so it is necessary to avoid retries in this scenario as much as possible. + * During the execution phase, when encountering a location exception for the first time, + * try to refresh the location once synchronously. + * If it fails, then proceed with statement-level retries.*/ + if (OB_FAIL(block_renew_tablet_location(tablet_id, location))) { + LOG_WARN("block renew tablet location failed", K(ret), K(tablet_id)); + } + } } + save_cur_exec_status(ret); return ret; } @@ -870,22 +908,6 @@ int ObDASLocationRouter::nonblock_get_candi_tablet_locations(const ObDASTableLoc K(ret),K(i), K(location), K(candi_tablet_locs), K(tablet_ids), K(partition_ids)); } } // for end - //When the OB_MAPPING_BETWEEN_TABLET_AND_LS_NOT_EXIST error is encountered, - //it means that the tablet mapper have been updated, - //and it is necessary to record all the tablet ids that have been touched by this query, - //and at the end of this query, - //the mapping relationship of these tablet ids need to be refreshed; - if (OB_MAPPING_BETWEEN_TABLET_AND_LS_NOT_EXIST == ret && i < N) { - int save_ret = OB_SUCCESS; - for (; OB_SUCCESS == save_ret && i < N; i++) { - if (OB_SUCCESS != (save_ret = all_tablet_list_.push_back(tablet_ids.at(i)))) { - LOG_WARN("save the remaining tablet id failed", K(ret), K(save_ret)); - } - } - if (save_ret != OB_SUCCESS) { - ret = save_ret; - } - } } NG_TRACE(get_location_cache_end); return ret; @@ -902,33 +924,13 @@ int ObDASLocationRouter::get_tablet_loc(const ObDASTableLocMeta &loc_meta, if (OB_FAIL(get_vt_tablet_loc(loc_meta.ref_table_id_, tablet_id, tablet_loc))) { LOG_WARN("get virtual tablet loc failed", K(ret), K(loc_meta)); } - } else if (OB_FAIL(all_tablet_list_.push_back(tablet_id))) { - LOG_WARN("store tablet id failed", K(ret)); } else { - int64_t retry_cnt = 0; - bool need_retry = false; - do { - need_retry = false; - if (OB_LIKELY(loc_meta.select_leader_) || OB_UNLIKELY(last_errno_ == OB_NOT_MASTER)) { - //if this statement is retried because of OB_NOT_MASTER, we will choose the leader directly - ret = nonblock_get_leader(tenant_id, tablet_id, tablet_loc); - } else { - ret = nonblock_get_readable_replica(tenant_id, tablet_id, tablet_loc); - } - if (is_partition_change_error(ret) && OB_SUCCESS == last_errno_ && retry_cnt <= 0) { - /*During the execution phase, if nonblock location interface is used to obtain the location - * and an exception occurs, retries are necessary. - * However, statement-level retries cannot rollback many execution states, - * so it is necessary to avoid retries in this scenario as much as possible. - * During the execution phase, when encountering a location exception for the first time, - * try to refresh the location once synchronously. - * If it fails, then proceed with statement-level retries.*/ - need_retry = true; - ++retry_cnt; - refresh_location_cache(tablet_id, false, ret); - ret = OB_SUCCESS; - } - } while (OB_SUCCESS == ret && need_retry); + if (OB_LIKELY(loc_meta.select_leader_) || OB_UNLIKELY(last_errno_ == OB_NOT_MASTER)) { + //if this statement is retried because of OB_NOT_MASTER, we will choose the leader directly + ret = nonblock_get_leader(tenant_id, tablet_id, tablet_loc); + } else { + ret = nonblock_get_readable_replica(tenant_id, tablet_id, tablet_loc); + } } return ret; } @@ -940,14 +942,36 @@ int ObDASLocationRouter::nonblock_get_leader(const uint64_t tenant_id, int ret = OB_SUCCESS; bool is_cache_hit = false; tablet_loc.tablet_id_ = tablet_id; - if (OB_FAIL(GCTX.location_service_->nonblock_get(tenant_id, tablet_id, tablet_loc.ls_id_))) { - LOG_WARN("nonblock get ls id failed", K(ret)); + if (OB_FAIL(all_tablet_list_.push_back(tablet_id))) { + LOG_WARN("store access tablet id failed", K(ret), K(tablet_id)); + } else if (OB_FAIL(GCTX.location_service_->nonblock_get(tenant_id, + tablet_id, + tablet_loc.ls_id_))) { + LOG_WARN("nonblock get ls id failed", K(ret), K(tablet_id)); } else if (OB_FAIL(GCTX.location_service_->nonblock_get_leader(GCONF.cluster_id, tenant_id, tablet_loc.ls_id_, tablet_loc.server_))) { LOG_WARN("nonblock get ls location failed", K(ret), K(tablet_loc)); } + if (is_partition_change_error(ret) && OB_SUCCESS == last_errno_ && retry_cnt_ <= 0) { + /*During the execution phase, if nonblock location interface is used to obtain the location + * and an exception occurs, retries are necessary. + * However, statement-level retries cannot rollback many execution states, + * so it is necessary to avoid retries in this scenario as much as possible. + * During the execution phase, when encountering a location exception for the first time, + * try to refresh the location once synchronously. + * If it fails, then proceed with statement-level retries.*/ + ObLSLocation ls_loc; + if (OB_FAIL(block_renew_tablet_location(tablet_id, ls_loc))) { + LOG_WARN("block renew tablet location failed", K(ret), K(tablet_id)); + } else if (OB_FAIL(ls_loc.get_leader(tablet_loc.server_))) { + LOG_WARN("get leader of ls location failed", K(ret), K(tablet_id), K(ls_loc)); + } else { + tablet_loc.ls_id_ = ls_loc.get_ls_id(); + } + } + save_cur_exec_status(ret); return ret; } @@ -1135,37 +1159,45 @@ void ObDASLocationRouter::refresh_location_cache(const ObTabletID &tablet_id, LOG_INFO("LOCATION: nonblock renew success", K(tablet_id), K(err_no)); } } else { - const int64_t expire_renew_time = INT64_MAX; // means must renew location - bool is_cache_hit = false; ObLSLocation dummy_loc; - ObLSID ls_id; - int64_t query_timeout_ts = THIS_WORKER.get_timeout_ts(); - int64_t now = ObTimeUtility::current_time(); - if (query_timeout_ts - now > 1 * 1000L * 1000L) { - //the timeout limit for "refresh location" is within 1s - THIS_WORKER.set_timeout_ts(now + 1 * 1000L * 1000L); + if (OB_FAIL(block_renew_tablet_location(tablet_id, dummy_loc))) { + LOG_WARN("fail to renew tablet location", K(ret), K(tablet_id)); } - if (OB_FAIL(GCTX.location_service_->get(MTL_ID(), - tablet_id, - expire_renew_time, - is_cache_hit, - ls_id))) { - LOG_WARN("fail to get ls id", K(ret)); - } else if (OB_FAIL(GCTX.location_service_->get(GCONF.cluster_id, - MTL_ID(), - ls_id, - expire_renew_time, - is_cache_hit, - dummy_loc))) { - LOG_WARN("failed to get location", K(ls_id), K(ret)); - } else { - LOG_INFO("LOCATION: refresh table cache succ", K(tablet_id), K(err_no), K(dummy_loc)); - } - //recover query timeout ts - THIS_WORKER.set_timeout_ts(query_timeout_ts); } } +int ObDASLocationRouter::block_renew_tablet_location(const ObTabletID &tablet_id, ObLSLocation &ls_loc) +{ + int ret = OB_SUCCESS; + const int64_t expire_renew_time = INT64_MAX; // means must renew location + bool is_cache_hit = false; + ObLSID ls_id; + int64_t query_timeout_ts = THIS_WORKER.get_timeout_ts(); + ObTimeoutCtx timeout_ctx; + timeout_ctx.set_timeout(1 * 1000L * 1000L); + //the timeout limit for "refresh location" is within 1s + THIS_WORKER.set_timeout_ts(timeout_ctx.get_abs_timeout(query_timeout_ts)); + if (OB_FAIL(GCTX.location_service_->get(MTL_ID(), + tablet_id, + expire_renew_time, + is_cache_hit, + ls_id))) { + LOG_WARN("fail to get ls id", K(ret)); + } else if (OB_FAIL(GCTX.location_service_->get(GCONF.cluster_id, + MTL_ID(), + ls_id, + expire_renew_time, + is_cache_hit, + ls_loc))) { + LOG_WARN("failed to get location", K(ls_id), K(ret)); + } else { + LOG_INFO("LOCATION: block refresh table cache succ", K(tablet_id), K(ls_loc)); + } + //recover query timeout ts + THIS_WORKER.set_timeout_ts(query_timeout_ts); + return ret; +} + void ObDASLocationRouter::set_retry_info(const ObQueryRetryInfo* retry_info) { last_errno_ = retry_info->get_last_query_retry_err(); diff --git a/src/sql/das/ob_das_location_router.h b/src/sql/das/ob_das_location_router.h index c981a576e7..34b0d8f1df 100644 --- a/src/sql/das/ob_das_location_router.h +++ b/src/sql/das/ob_das_location_router.h @@ -136,7 +136,7 @@ public: map_.clear(); } const RelatedTabletList &get_list() const { return list_; } - TO_STRING_KV(K_(list)); + TO_STRING_KV(K_(list), "map_size", map_.size()); private: const int64_t FAST_LOOP_LIST_LEN = 100; //There are usually not many tablets for a query. @@ -279,6 +279,7 @@ class ObDASLocationRouter typedef common::ObList VirtualSvrList; public: ObDASLocationRouter(common::ObIAllocator &allocator); + ~ObDASLocationRouter(); int nonblock_get(const ObDASTableLocMeta &loc_meta, const common::ObTabletID &tablet_id, share::ObLSLocation &location); @@ -292,18 +293,19 @@ public: int get_tablet_loc(const ObDASTableLocMeta &loc_meta, const common::ObTabletID &tablet_id, ObDASTabletLoc &tablet_loc); - static int nonblock_get_leader(const uint64_t tenant_id, - const ObTabletID &tablet_id, - ObDASTabletLoc &tablet_loc); - static int get_leader(const uint64_t tenant_id, - const common::ObTabletID &tablet_id, - ObAddr &leader_addr, - int64_t expire_renew_time); + int nonblock_get_leader(const uint64_t tenant_id, + const ObTabletID &tablet_id, + ObDASTabletLoc &tablet_loc); + int get_leader(const uint64_t tenant_id, + const common::ObTabletID &tablet_id, + ObAddr &leader_addr, + int64_t expire_renew_time); int get_full_ls_replica_loc(const common::ObObjectID &tenant_id, const ObDASTabletLoc &tablet_loc, share::ObLSReplicaLocation &replica_loc); void refresh_location_cache(bool is_nonblock, int err_no); void refresh_location_cache(const common::ObTabletID &tablet_id, bool is_nonblock, int err_no); + int block_renew_tablet_location(const common::ObTabletID &tablet_id, share::ObLSLocation &ls_loc); int save_touched_tablet_id(const common::ObTabletID &tablet_id) { return all_tablet_list_.push_back(tablet_id); } void set_last_errno(int err_no) { last_errno_ = err_no; } void set_retry_cnt(int64_t retry_cnt) { retry_cnt_ = retry_cnt; } @@ -311,6 +313,13 @@ public: void set_retry_info(const ObQueryRetryInfo* retry_info); int64_t get_retry_cnt() const { return retry_cnt_; } int get_external_table_ls_location(share::ObLSLocation &location); + void save_cur_exec_status(int err_no) + { + if (OB_SUCCESS == cur_errno_) { + //can't cover the first error code + cur_errno_ = err_no; + } + } private: int get_vt_svr_pair(uint64_t vt_id, const VirtualSvrPair *&vt_svr_pair); int get_vt_tablet_loc(uint64_t table_id, @@ -324,6 +333,7 @@ private: ObDASTabletLoc &tablet_loc); private: int last_errno_; + int cur_errno_; int64_t retry_cnt_; ObList all_tablet_list_; VirtualSvrList virtual_server_list_; diff --git a/src/sql/das/ob_data_access_service.cpp b/src/sql/das/ob_data_access_service.cpp index 10f6ab597a..7d70cddd71 100644 --- a/src/sql/das/ob_data_access_service.cpp +++ b/src/sql/das/ob_data_access_service.cpp @@ -107,6 +107,7 @@ int ObDataAccessService::execute_das_task( } else if (OB_FAIL(execute_dist_das_task(das_ref, task_ops, async))) { LOG_WARN("failed to execute dist das task", K(ret)); } + DAS_CTX(das_ref.get_exec_ctx()).get_location_router().save_cur_exec_status(ret); return ret; } @@ -607,7 +608,7 @@ int ObDataAccessService::process_task_resp(ObDASRef &das_ref, const ObDASTaskRes } // task_resp's error code indicate the last valid op result. if (OB_FAIL(task_resp.get_err_code())) { - LOG_WARN("error occurring in remote das task", K(ret)); + LOG_WARN("error occurring in remote das task", K(ret), K(task_resp)); OB_ASSERT(op_results.count() <= task_ops.count()); } else { // decode last op result @@ -653,6 +654,7 @@ int ObDataAccessService::process_task_resp(ObDASRef &das_ref, const ObDASTaskRes ret = COVER_SUCC(save_ret); } } + DAS_CTX(das_ref.get_exec_ctx()).get_location_router().save_cur_exec_status(ret); return ret; } diff --git a/src/sql/engine/cmd/ob_load_data_impl.cpp b/src/sql/engine/cmd/ob_load_data_impl.cpp index c3b59f6a9e..b92ef29b5e 100644 --- a/src/sql/engine/cmd/ob_load_data_impl.cpp +++ b/src/sql/engine/cmd/ob_load_data_impl.cpp @@ -344,9 +344,9 @@ int ObLoadDataBase::memory_wait_local(ObExecContext &ctx, K(tablet_id), K(server_addr), K(total_wait_secs)); } - bool force_renew = false; bool need_wait_freeze = true; ObAddr leader_addr; + ObDASLocationRouter &loc_router = DAS_CTX(ctx).get_location_router(); while (OB_SUCC(ret) && need_wait_freeze) { @@ -355,26 +355,17 @@ int ObLoadDataBase::memory_wait_local(ObExecContext &ctx, leader_addr.reset(); res.reuse(); char leader_ip_str[MAX_IP_ADDR_LENGTH]; - bool force_renew = false; - do { - const int64_t retry_us = 200 * 1000; - const int64_t expire_renew_time = 2 * 1000000; // 2s - if (OB_FAIL(ObLoadDataUtils::check_session_status(*session))) { - LOG_WARN("session is not valid during wait", K(ret)); - } else if (OB_FAIL(ObDASLocationRouter::get_leader(tenant_id, tablet_id, leader_addr, expire_renew_time))) { - if (is_location_service_renew_error(ret) && !force_renew) { - // retry one time - force_renew = true; - LOG_WARN("failed to get location and force renew", K(ret)); - } else { - LOG_WARN("failed to get location", K(ret)); - ob_usleep(retry_us); - } - } else { - force_renew = false; - LOG_DEBUG("get participants", K(tablet_id), K(leader_addr)); - } - } while (is_location_service_renew_error(ret) && force_renew); + const int64_t retry_us = 200 * 1000; + //Try to use the results in the cache as much as possible, without forcing a cache refresh. + const int64_t expire_renew_time = 0; + if (OB_FAIL(ObLoadDataUtils::check_session_status(*session))) { + LOG_WARN("session is not valid during wait", K(ret)); + } else if (OB_FAIL(loc_router.get_leader(tenant_id, tablet_id, leader_addr, expire_renew_time))) { + LOG_WARN("failed to get location", K(ret)); + ob_usleep(retry_us); + } else { + LOG_DEBUG("get participants", K(tablet_id), K(leader_addr)); + } if (OB_FAIL(ret)) { } else if (!leader_addr.ip_to_string(leader_ip_str, sizeof(leader_ip_str))) { @@ -393,16 +384,16 @@ int ObLoadDataBase::memory_wait_local(ObExecContext &ctx, } else if (OB_FAIL(result->next())) { LOG_WARN("fail to get result, force renew location", K(ret), K(leader_addr)); if (OB_ITER_END == ret) { - force_renew = true; ret = OB_SUCCESS; } } else { - force_renew = false; EXTRACT_BOOL_FIELD_MYSQL(*result, "need_wait_freeze", need_wait_freeze); //LOG_INFO("LOAD DATA is waiting for tenant memory available", //K(waited_seconds), K(total_wait_secs), K(tenant_id)); } - + //if it is location exception, refresh location cache with block interface + //because load data can only local retry + loc_router.refresh_location_cache(false, ret); } //print info @@ -2276,9 +2267,10 @@ int ObPartDataFragMgr::update_part_location(ObExecContext &ctx) LOG_WARN("invalid partition key", K(ret)); } else { bool force_renew = false; - const int64_t expire_renew_time = 2 * 1000000; // 2s + ObDASLocationRouter &loc_router = DAS_CTX(ctx).get_location_router(); do { - if (OB_FAIL(ObDASLocationRouter::get_leader(tenant_id_, tablet_id_, leader_addr_, expire_renew_time))) { + const int64_t expire_renew_time = force_renew ? INT64_MAX : 0; + if (OB_FAIL(loc_router.get_leader(tenant_id_, tablet_id_, leader_addr_, expire_renew_time))) { if (is_location_service_renew_error(ret) && !force_renew) { // retry one time force_renew = true; diff --git a/src/sql/engine/px/ob_dfo_mgr.cpp b/src/sql/engine/px/ob_dfo_mgr.cpp index 7ffb1e0d7c..bcbfd91291 100644 --- a/src/sql/engine/px/ob_dfo_mgr.cpp +++ b/src/sql/engine/px/ob_dfo_mgr.cpp @@ -477,11 +477,12 @@ int ObDfoMgr::do_split(ObExecContext &exec_ctx, ObDASTableLoc *table_loc = nullptr; if (OB_ISNULL(table_loc = DAS_CTX(exec_ctx).get_table_loc_by_id( tsc_op->get_table_loc_id(), tsc_op->get_loc_ref_table_id()))) { - OZ(ObTableLocation::get_full_leader_table_loc(exec_ctx.get_allocator(), - exec_ctx.get_my_session()->get_effective_tenant_id(), - tsc_op->get_table_loc_id(), - tsc_op->get_loc_ref_table_id(), - table_loc)); + OZ(ObTableLocation::get_full_leader_table_loc(DAS_CTX(exec_ctx).get_location_router(), + exec_ctx.get_allocator(), + exec_ctx.get_my_session()->get_effective_tenant_id(), + tsc_op->get_table_loc_id(), + tsc_op->get_loc_ref_table_id(), + table_loc)); } if (OB_FAIL(ret)) { } else { diff --git a/src/sql/engine/px/ob_px_sub_coord.cpp b/src/sql/engine/px/ob_px_sub_coord.cpp index 22a625b538..92c9f3576d 100644 --- a/src/sql/engine/px/ob_px_sub_coord.cpp +++ b/src/sql/engine/px/ob_px_sub_coord.cpp @@ -913,7 +913,9 @@ int ObPxSubCoord::rebuild_sqc_access_table_locations() for (int i = 0; i < location_keys.count() && OB_SUCC(ret); ++i) { // dml location always at first if (OB_ISNULL(table_loc) && location_keys.at(i).is_loc_uncertain_) { - OZ(ObTableLocation::get_full_leader_table_loc(sqc_arg_.exec_ctx_->get_allocator(), + ObDASLocationRouter &loc_router = DAS_CTX(*sqc_arg_.exec_ctx_).get_location_router(); + OZ(ObTableLocation::get_full_leader_table_loc(loc_router, + sqc_arg_.exec_ctx_->get_allocator(), sqc_arg_.exec_ctx_->get_my_session()->get_effective_tenant_id(), location_keys.at(i).table_location_key_, location_keys.at(i).ref_table_id_, diff --git a/src/sql/engine/px/ob_px_util.cpp b/src/sql/engine/px/ob_px_util.cpp index 1bc2c3d442..3010ca7061 100644 --- a/src/sql/engine/px/ob_px_util.cpp +++ b/src/sql/engine/px/ob_px_util.cpp @@ -317,11 +317,12 @@ int ObPXServerAddrUtil::alloc_by_data_distribution_inner( } else if (dml_op && dml_op->is_table_location_uncertain()) { // 需要获取FULL TABLE LOCATION. FIX ME YISHEN. CK(OB_NOT_NULL(ctx.get_my_session())); - OZ(ObTableLocation::get_full_leader_table_loc(ctx.get_allocator(), - ctx.get_my_session()->get_effective_tenant_id(), - table_location_key, - ref_table_id, - table_loc)); + OZ(ObTableLocation::get_full_leader_table_loc(DAS_CTX(ctx).get_location_router(), + ctx.get_allocator(), + ctx.get_my_session()->get_effective_tenant_id(), + table_location_key, + ref_table_id, + table_loc)); } else { if (OB_NOT_NULL(scan_op) && scan_op->is_external_table_) { // create new table loc for a random dfo distribution for external table @@ -953,11 +954,12 @@ int ObPXServerAddrUtil::set_dfo_accessed_location(ObExecContext &ctx, } else { if (dml_op->is_table_location_uncertain()) { CK(OB_NOT_NULL(ctx.get_my_session())); - OZ(ObTableLocation::get_full_leader_table_loc(ctx.get_allocator(), - ctx.get_my_session()->get_effective_tenant_id(), - table_location_key, - ref_table_id, - table_loc)); + OZ(ObTableLocation::get_full_leader_table_loc(DAS_CTX(ctx).get_location_router(), + ctx.get_allocator(), + ctx.get_my_session()->get_effective_tenant_id(), + table_location_key, + ref_table_id, + table_loc)); } else { // 通过TSC或者DML获得当前的DFO的partition对应的location信息 // 后续利用location信息构建对应的SQC meta diff --git a/src/sql/optimizer/ob_phy_table_location_info.cpp b/src/sql/optimizer/ob_phy_table_location_info.cpp index 9b28fbefa2..7c6f053768 100644 --- a/src/sql/optimizer/ob_phy_table_location_info.cpp +++ b/src/sql/optimizer/ob_phy_table_location_info.cpp @@ -596,7 +596,8 @@ int ObCandiTableLoc::replace_local_index_loc(DASRelatedTabletMap &map, ObTableID const DASRelatedTabletMap::Value *rv = nullptr; if (OB_ISNULL(rv = map.get_related_tablet_id(tablet_loc.get_tablet_id(), ref_table_id))) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("related tablet info is invalid", K(ret), K(tablet_loc.get_tablet_id()), K(ref_table_id)); + LOG_WARN("related tablet info is invalid", K(ret), + K(tablet_loc.get_tablet_id()), K(ref_table_id), K(map)); } else { tablet_loc.set_tablet_info(rv->tablet_id_, rv->part_id_, rv->first_level_part_id_); } diff --git a/src/sql/optimizer/ob_table_location.cpp b/src/sql/optimizer/ob_table_location.cpp index 111893f8fb..c1ef72254d 100644 --- a/src/sql/optimizer/ob_table_location.cpp +++ b/src/sql/optimizer/ob_table_location.cpp @@ -5290,7 +5290,8 @@ int ObTableLocation::try_split_integer_range(const common::ObIArrayloc_meta_ = loc_meta); OX(tablet_loc->partition_id_ = partition_ids.at(i)); OX(tablet_loc->first_level_part_id_ = first_level_part_ids.at(i)); - OZ(ObDASLocationRouter::nonblock_get_leader(tenant_id, tablet_ids.at(i), *tablet_loc)); + OZ(loc_router.nonblock_get_leader(tenant_id, tablet_ids.at(i), *tablet_loc)); OZ(table_loc->add_tablet_loc(tablet_loc)); } } diff --git a/src/sql/optimizer/ob_table_location.h b/src/sql/optimizer/ob_table_location.h index f73c0e8b69..3bb1aa20a4 100644 --- a/src/sql/optimizer/ob_table_location.h +++ b/src/sql/optimizer/ob_table_location.h @@ -699,7 +699,8 @@ public: common::ObIArray *sort_exprs) const; bool has_generated_column() const { return NULL != se_gen_col_expr_ || NULL != se_sub_gen_col_expr_ || NULL != gen_col_node_ || NULL != sub_gen_col_node_; } - static int get_full_leader_table_loc(ObIAllocator &allocator, + static int get_full_leader_table_loc(ObDASLocationRouter &loc_router, + ObIAllocator &allocator, uint64_t tenant_id, uint64_t table_id, uint64_t ref_table_id,