fix get unexpected error caused by getting invalid dynamic sampling table
This commit is contained in:
@ -45,7 +45,7 @@ int ObAccessPathEstimation::estimate_rowcount(ObOptimizerContext &ctx,
|
|||||||
LOG_WARN("failed to get valid est methods", K(ret));
|
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, method))) {
|
||||||
LOG_WARN("failed to choose one est method", K(ret), K(valid_methods));
|
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, method))) {
|
} 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));
|
LOG_WARN("failed to do estimate rowcount", K(ret), K(method), K(valid_methods));
|
||||||
}
|
}
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < paths.count(); i ++) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < paths.count(); i ++) {
|
||||||
@ -63,6 +63,7 @@ int ObAccessPathEstimation::do_estimate_rowcount(ObOptimizerContext &ctx,
|
|||||||
common::ObIArray<AccessPath*> &paths,
|
common::ObIArray<AccessPath*> &paths,
|
||||||
const bool is_inner_path,
|
const bool is_inner_path,
|
||||||
const ObIArray<ObRawExpr*> &filter_exprs,
|
const ObIArray<ObRawExpr*> &filter_exprs,
|
||||||
|
ObBaseTableEstMethod &valid_methods,
|
||||||
ObBaseTableEstMethod &method)
|
ObBaseTableEstMethod &method)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
@ -82,9 +83,11 @@ int ObAccessPathEstimation::do_estimate_rowcount(ObOptimizerContext &ctx,
|
|||||||
ctx, paths, is_inner_path, filter_exprs, only_ds_basic_stat, is_success))) {
|
ctx, paths, is_inner_path, filter_exprs, only_ds_basic_stat, is_success))) {
|
||||||
LOG_WARN("failed to process statistics estimation", K(ret));
|
LOG_WARN("failed to process statistics estimation", K(ret));
|
||||||
} else if (!is_success) {
|
} else if (!is_success) {
|
||||||
method &= ~EST_DS_BASIC;
|
valid_methods &= ~EST_DS_BASIC;
|
||||||
method &= ~EST_DS_FULL;
|
valid_methods &= ~EST_DS_FULL;
|
||||||
method |= EST_DEFAULT;
|
if (OB_FAIL(choose_best_est_method(ctx, paths, filter_exprs, valid_methods, method))) {
|
||||||
|
LOG_WARN("failed to choose one est method", K(ret), K(valid_methods));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +212,6 @@ int ObAccessPathEstimation::check_can_use_dynamic_sampling(ObOptimizerContext &c
|
|||||||
int64_t sample_block_cnt = 0;
|
int64_t sample_block_cnt = 0;
|
||||||
bool specify_ds = false;
|
bool specify_ds = false;
|
||||||
bool has_invalid_ds_filters = false;
|
bool has_invalid_ds_filters = false;
|
||||||
int64_t max_ds_timeout = 0;
|
|
||||||
const ObBaseTableEstMethod EST_DS_METHODS = EST_DS_BASIC | EST_DS_FULL;
|
const ObBaseTableEstMethod EST_DS_METHODS = EST_DS_BASIC | EST_DS_FULL;
|
||||||
if (OB_FAIL(ObDynamicSamplingUtils::get_valid_dynamic_sampling_level(
|
if (OB_FAIL(ObDynamicSamplingUtils::get_valid_dynamic_sampling_level(
|
||||||
ctx.get_session_info(),
|
ctx.get_session_info(),
|
||||||
@ -219,10 +221,8 @@ int ObAccessPathEstimation::check_can_use_dynamic_sampling(ObOptimizerContext &c
|
|||||||
sample_block_cnt,
|
sample_block_cnt,
|
||||||
specify_ds))) {
|
specify_ds))) {
|
||||||
LOG_WARN("failed to get valid dynamic sampling level", K(ret));
|
LOG_WARN("failed to get valid dynamic sampling level", K(ret));
|
||||||
} else if (OB_FAIL(ObDynamicSamplingUtils::get_dynamic_sampling_max_timeout(ctx, max_ds_timeout))) {
|
|
||||||
LOG_WARN("failed to get dynamic sampling max timeout", K(ret));
|
|
||||||
} else if (ObDynamicSamplingLevel::NO_DYNAMIC_SAMPLING == ds_level ||
|
} else if (ObDynamicSamplingLevel::NO_DYNAMIC_SAMPLING == ds_level ||
|
||||||
max_ds_timeout <= 0) {
|
ObDynamicSamplingUtils::get_dynamic_sampling_max_timeout(ctx) <= 0) {
|
||||||
valid_methods &= ~EST_DS_METHODS;
|
valid_methods &= ~EST_DS_METHODS;
|
||||||
} else if (ObDynamicSamplingUtils::check_is_failed_ds_table(table_meta.get_ref_table_id(),
|
} else if (ObDynamicSamplingUtils::check_is_failed_ds_table(table_meta.get_ref_table_id(),
|
||||||
table_meta.get_all_used_parts(),
|
table_meta.get_all_used_parts(),
|
||||||
@ -1671,8 +1671,7 @@ int ObAccessPathEstimation::process_dynamic_sampling_estimation(ObOptimizerConte
|
|||||||
ds_table_param, specify_ds))) {
|
ds_table_param, specify_ds))) {
|
||||||
LOG_WARN("failed to get ds table param", K(ret), K(ds_table_param));
|
LOG_WARN("failed to get ds table param", K(ret), K(ds_table_param));
|
||||||
} else if (!ds_table_param.is_valid()) {
|
} else if (!ds_table_param.is_valid()) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
is_success = false;
|
||||||
LOG_WARN("get invalid ds table param", K(ret), K(ds_table_param));
|
|
||||||
} else if (OB_FAIL(add_ds_result_items(paths, filter_exprs, specify_ds,
|
} else if (OB_FAIL(add_ds_result_items(paths, filter_exprs, specify_ds,
|
||||||
ds_result_items, only_ds_basic_stat))) {
|
ds_result_items, only_ds_basic_stat))) {
|
||||||
LOG_WARN("failed to init ds result items", K(ret));
|
LOG_WARN("failed to init ds result items", K(ret));
|
||||||
|
@ -89,6 +89,7 @@ private:
|
|||||||
common::ObIArray<AccessPath*> &paths,
|
common::ObIArray<AccessPath*> &paths,
|
||||||
const bool is_inner_path,
|
const bool is_inner_path,
|
||||||
const ObIArray<ObRawExpr*> &filter_exprs,
|
const ObIArray<ObRawExpr*> &filter_exprs,
|
||||||
|
ObBaseTableEstMethod &valid_methods,
|
||||||
ObBaseTableEstMethod &method);
|
ObBaseTableEstMethod &method);
|
||||||
|
|
||||||
static int process_common_estimate_rowcount(ObOptimizerContext &ctx,
|
static int process_common_estimate_rowcount(ObOptimizerContext &ctx,
|
||||||
|
@ -1308,9 +1308,7 @@ int ObDynamicSamplingUtils::get_ds_table_param(ObOptimizerContext &ctx,
|
|||||||
table_meta->get_ref_table_id(),
|
table_meta->get_ref_table_id(),
|
||||||
ds_table_param.degree_))) {
|
ds_table_param.degree_))) {
|
||||||
LOG_WARN("failed to get ds table degree", K(ret));
|
LOG_WARN("failed to get ds table degree", K(ret));
|
||||||
} else if (OB_FAIL(get_dynamic_sampling_max_timeout(ctx, ds_table_param.max_ds_timeout_))) {
|
} else if ((ds_table_param.max_ds_timeout_ = get_dynamic_sampling_max_timeout(ctx)) > 0) {
|
||||||
LOG_WARN("failed to get dynamic sampling max timeout", K(ret));
|
|
||||||
} else {
|
|
||||||
ds_table_param.tenant_id_ = ctx.get_session_info()->get_effective_tenant_id();
|
ds_table_param.tenant_id_ = ctx.get_session_info()->get_effective_tenant_id();
|
||||||
ds_table_param.table_id_ = table_meta->get_ref_table_id();
|
ds_table_param.table_id_ = table_meta->get_ref_table_id();
|
||||||
ds_table_param.ds_level_ = ds_level;
|
ds_table_param.ds_level_ = ds_level;
|
||||||
@ -1521,15 +1519,11 @@ const ObDSResultItem *ObDynamicSamplingUtils::get_ds_result_item(ObDSResultItemT
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObDynamicSamplingUtils::get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx,
|
int64_t ObDynamicSamplingUtils::get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx)
|
||||||
int64_t &max_ds_timeout)
|
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int64_t max_ds_timeout = 0;
|
||||||
if (OB_FAIL(THIS_WORKER.check_status())) {
|
if (THIS_WORKER.get_timeout_remain() / 10 >= OB_DS_MIN_QUERY_TIMEOUT) {
|
||||||
LOG_WARN("failed to check status", K(ret));
|
max_ds_timeout = THIS_WORKER.get_timeout_remain() / 10;//default ds time can't exceed 10% of current sql remain timeout
|
||||||
} else {
|
|
||||||
max_ds_timeout = THIS_WORKER.get_timeout_remain();
|
|
||||||
max_ds_timeout = max_ds_timeout / 10;//default ds time can't exceed 10% of current sql remain timeout
|
|
||||||
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(ctx.get_session_info()->get_effective_tenant_id()));
|
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(ctx.get_session_info()->get_effective_tenant_id()));
|
||||||
if (tenant_config.is_valid()) {
|
if (tenant_config.is_valid()) {
|
||||||
int64_t ds_maximum_time = tenant_config->_optimizer_ads_time_limit * 1000000;
|
int64_t ds_maximum_time = tenant_config->_optimizer_ads_time_limit * 1000000;
|
||||||
@ -1538,7 +1532,7 @@ int ObDynamicSamplingUtils::get_dynamic_sampling_max_timeout(ObOptimizerContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return max_ds_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObDynamicSamplingUtils::add_failed_ds_table_list(const uint64_t table_id,
|
int ObDynamicSamplingUtils::add_failed_ds_table_list(const uint64_t table_id,
|
||||||
|
@ -199,6 +199,7 @@ static T *copy_ds_stat_item(ObIAllocator &allocator, const T &src)
|
|||||||
|
|
||||||
const int64_t OB_DS_BASIC_SAMPLE_MICRO_CNT = 32;
|
const int64_t OB_DS_BASIC_SAMPLE_MICRO_CNT = 32;
|
||||||
const int64_t OB_DS_MAX_FILTER_EXPR_COUNT = 10000;
|
const int64_t OB_DS_MAX_FILTER_EXPR_COUNT = 10000;
|
||||||
|
const int64_t OB_DS_MIN_QUERY_TIMEOUT = 1000;//Dynamic sampling requires a minimum timeout of 1ms.
|
||||||
//const int64_t OB_OPT_DS_ADAPTIVE_SAMPLE_MICRO_CNT = 200;
|
//const int64_t OB_OPT_DS_ADAPTIVE_SAMPLE_MICRO_CNT = 200;
|
||||||
//const int64_t OB_OPT_DS_MAX_TIMES = 7;
|
//const int64_t OB_OPT_DS_MAX_TIMES = 7;
|
||||||
|
|
||||||
@ -366,8 +367,7 @@ public:
|
|||||||
uint64_t index_id,
|
uint64_t index_id,
|
||||||
const ObIArray<ObDSResultItem> &ds_result_items);
|
const ObIArray<ObDSResultItem> &ds_result_items);
|
||||||
|
|
||||||
static int get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx,
|
static int64_t get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx);
|
||||||
int64_t &max_ds_timeout);
|
|
||||||
|
|
||||||
static int add_failed_ds_table_list(const uint64_t table_id,
|
static int add_failed_ds_table_list(const uint64_t table_id,
|
||||||
const common::ObIArray<int64_t> &used_part_id,
|
const common::ObIArray<int64_t> &used_part_id,
|
||||||
|
Reference in New Issue
Block a user