[CP] fix some optimizer stats bug

This commit is contained in:
wangt1xiuyi
2024-04-08 07:24:46 +00:00
committed by ob-robot
parent 648c9b98b5
commit 73cc1ad061
7 changed files with 116 additions and 75 deletions

View File

@ -1143,15 +1143,20 @@ OB_NOINLINE int ObDASLocationRouter::get_vt_ls_location(uint64_t table_id,
return ret;
}
bool ObDASLocationRouter::is_refresh_location_error(int err_no) const
{
return is_master_changed_error(err_no) ||
is_partition_change_error(err_no) ||
is_get_location_timeout_error(err_no) ||
is_server_down_error(err_no) ||
is_has_no_readable_replica_err(err_no) ||
is_unit_migrate(err_no);
}
void ObDASLocationRouter::refresh_location_cache_by_errno(bool is_nonblock, int err_no)
{
NG_TRACE_TIMES(1, get_location_cache_begin);
if (is_master_changed_error(err_no)
|| is_partition_change_error(err_no)
|| is_get_location_timeout_error(err_no)
|| is_server_down_error(err_no)
|| is_has_no_readable_replica_err(err_no)
|| is_unit_migrate(err_no)) {
if (is_refresh_location_error(err_no)) {
// Refresh tablet ls mapping and ls locations according to err_no.
//
// The timeout has been set inner the interface when renewing location synchronously.

View File

@ -331,6 +331,7 @@ public:
}
int save_success_task(const common::ObTabletID &succ_id)
{ return succ_tablet_list_.push_back(succ_id); }
bool is_refresh_location_error(int err_no) const;
TO_STRING_KV(K(all_tablet_list_));
private:
int get_vt_svr_pair(uint64_t vt_id, const VirtualSvrPair *&vt_svr_pair);

View File

@ -65,13 +65,16 @@ int ObAccessPathEstimation::inner_estimate_rowcount(ObOptimizerContext &ctx,
const bool is_inner_path,
const ObIArray<ObRawExpr*> &filter_exprs,
ObBaseTableEstMethod &method)
{
{
int ret = OB_SUCCESS;
ObBaseTableEstMethod valid_methods = 0;
ObBaseTableEstMethod hint_specify_methods = 0;
method = EST_INVALID;
if (OB_FAIL(get_valid_est_methods(ctx, paths, filter_exprs, is_inner_path, valid_methods))) {
if (OB_FAIL(get_valid_est_methods(ctx, paths, filter_exprs, is_inner_path, valid_methods, hint_specify_methods))) {
LOG_WARN("failed to get valid est methods", K(ret));
} else if (OB_FAIL(choose_best_est_method(ctx, paths, filter_exprs, valid_methods, method))) {
} else if (OB_FAIL(choose_best_est_method(ctx, paths, filter_exprs,
valid_methods & hint_specify_methods ? valid_methods & hint_specify_methods : valid_methods,
method))) {
LOG_WARN("failed to choose one est method", K(ret), K(valid_methods));
} else if (OB_FAIL(do_estimate_rowcount(ctx, paths, is_inner_path, filter_exprs, valid_methods, method))) {
LOG_WARN("failed to do estimate rowcount", K(ret), K(method), K(valid_methods));
@ -146,12 +149,13 @@ int ObAccessPathEstimation::get_valid_est_methods(ObOptimizerContext &ctx,
common::ObIArray<AccessPath*> &paths,
const ObIArray<ObRawExpr*> &filter_exprs,
bool is_inner_path,
ObBaseTableEstMethod &valid_methods)
ObBaseTableEstMethod &valid_methods,
ObBaseTableEstMethod &hint_specify_methods)
{
int ret = OB_SUCCESS;
valid_methods = EST_DEFAULT | EST_STAT | EST_STORAGE | EST_DS_BASIC | EST_DS_FULL;
hint_specify_methods = 0;
const ObBaseTableEstMethod EST_DS_METHODS = EST_DS_BASIC | EST_DS_FULL;
ObBaseTableEstMethod hint_specify_methods = 0;
const ObLogPlan* log_plan = NULL;
const OptTableMeta *table_meta = NULL;
if (OB_UNLIKELY(paths.empty()) ||
@ -218,13 +222,6 @@ int ObAccessPathEstimation::get_valid_est_methods(ObOptimizerContext &ctx,
LOG_WARN("failed to check dynamic sampling", K(ret));
}
// if there are any valid hint_specify_method, use it.
if (OB_SUCC(ret)) {
if (valid_methods & hint_specify_methods) {
valid_methods &= hint_specify_methods;
}
}
return ret;
}

View File

@ -76,7 +76,8 @@ private:
common::ObIArray<AccessPath*> &paths,
const ObIArray<ObRawExpr*> &filter_exprs,
bool is_inner_path,
ObBaseTableEstMethod &valid_methods);
ObBaseTableEstMethod &valid_methods,
ObBaseTableEstMethod &hint_specify_methods);
static int check_can_use_dynamic_sampling(ObOptimizerContext &ctx,
const ObLogPlan &log_plan,