未use database的情况下创建outline,查询gv$outline时报-4016

This commit is contained in:
xy0
2022-02-28 20:15:44 +08:00
committed by LINxiansheng
parent 1b3e363de0
commit 0b3eff2515
3 changed files with 363 additions and 361 deletions

View File

@ -156,7 +156,8 @@ int ObTenantVirtualOutline::fill_cells(const ObOutlineInfo* outline_info)
}
case DATABASE_NAME: {
DBInfo db_info;
if (outline_info->get_database_id()==OB_OUTLINE_DEFAULT_DATABASE_ID) {
if (outline_info->get_database_id() ==
combine_id(outline_info->get_tenant_id(), OB_OUTLINE_DEFAULT_DATABASE_ID)) {
cells[cell_idx].set_varchar(OB_OUTLINE_DEFAULT_DATABASE_NAME);
cells[cell_idx].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
} else if (OB_FAIL(database_infos_.get_refactored(outline_info->get_database_id(), db_info))) {
@ -227,7 +228,8 @@ int ObTenantVirtualOutline::is_output_outline(const ObOutlineInfo* outline_info,
LOG_WARN("parameter is NULL", K(ret), K(outline_info), K(schema_guard_));
} else if (outline_info->get_outline_content_str().empty()) {
is_output = false;
} else if (outline_info->get_database_id() == OB_OUTLINE_DEFAULT_DATABASE_ID) {
} else if (outline_info->get_database_id() ==
combine_id(outline_info->get_tenant_id(), OB_OUTLINE_DEFAULT_DATABASE_ID)) {
// __outline_default_db is a logical table and has no physical schema.
// Therefore, always output this.
is_output = true;

View File

@ -646,8 +646,13 @@ int ObSql::do_real_prepare(const ObString& sql, ObSqlCtx& context, ObResultSet&
LOG_INFO("generate new stmt", K(param_cnt), K(stmt_type), K(normalized_sql), K(sql));
}
if (OB_SUCC(ret)) {
if (OB_FAIL(do_add_ps_cache(normalized_sql, param_cnt, *context.schema_guard_, stmt_type,
result, is_inner_sql, context.is_sensitive_))) {
if (OB_FAIL(do_add_ps_cache(normalized_sql,
param_cnt,
*context.schema_guard_,
stmt_type,
result,
is_inner_sql,
context.is_sensitive_))) {
LOG_WARN("add to ps plan cache failed", K(ret));
}
}
@ -1170,10 +1175,9 @@ inline int ObSql::handle_text_query(const ObString& stmt, ObSqlCtx& context, ObR
if (OB_FAIL(session.get_database_id(database_id))) {
LOG_WARN("Failed to get database id", K(ret));
} else if (FALSE_IT(pc_ctx->bl_key_.db_id_ =
(database_id == OB_INVALID_ID) ?
OB_OUTLINE_DEFAULT_DATABASE_ID:
database_id)) {
} else if (FALSE_IT(pc_ctx->bl_key_.db_id_ = (database_id == OB_INVALID_ID)
? combine_id(tenant_id, OB_OUTLINE_DEFAULT_DATABASE_ID)
: database_id)) {
// do nothing
} else if (!use_plan_cache) {
if (context.multi_stmt_item_.is_batched_multi_stmt()) {
@ -1616,8 +1620,8 @@ int ObSql::generate_physical_plan(ParseResult& parse_result, ObPlanCacheCtx* pc_
stmt))) { // rewrite stmt
LOG_WARN("Failed to transforme stmt", K(ret));
} else if (OB_FALSE_IT(optctx.set_root_stmt(stmt))) {
} else if (OB_FAIL(optimize_stmt(optimizer, *(sql_ctx.session_info_),
*stmt, logical_plan))) { //gen logical plan
} else if (OB_FAIL(
optimize_stmt(optimizer, *(sql_ctx.session_info_), *stmt, logical_plan))) { // gen logical plan
LOG_WARN("Failed to optimizer stmt", K(ret));
} else if (OB_ISNULL(logical_plan)) {
ret = OB_INVALID_ARGUMENT;
@ -2560,12 +2564,10 @@ int ObSql::execute_get_plan(ObPlanCache& plan_cache, ObPlanCacheCtx& pc_ctx, ObP
LOG_WARN("fail to get physical plan", K(ret));
}
}
// 如果是新引擎执行时出现get不到的情况, 则关闭新引擎, 重新再一次get, 避免出现因为新
// 引擎本身不支持的计划时, 生成的新计划是老的执行计划并加入到了plan cache,
// 而get时总get 不到老计划的情况
if (OB_SQL_PC_NOT_EXIST == ret
&& session->use_static_typing_engine()
&& !pc_ctx.is_remote_executor_) {
// if latest engine get plan fail at runtime, close that and retry to
// avoid case when unsupported plan generated, the new plan is the
// same as the old one and added into plan cache but the old one can not be got
if (OB_SQL_PC_NOT_EXIST == ret && session->use_static_typing_engine() && !pc_ctx.is_remote_executor_) {
ret = OB_SUCCESS;
session->set_use_static_typing_engine(false);
ObPhysicalPlanCtx *pctx = pc_ctx.exec_ctx_.get_physical_plan_ctx();
@ -3026,12 +3028,11 @@ int ObSql::after_get_plan(ObPlanCacheCtx& pc_ctx, ObSQLSessionInfo& session, ObP
bool enable_send_plan_event = EVENT_CALL(EventTable::EN_DISABLE_REMOTE_EXEC_WITH_PLAN) == 0;
bool enable_send_plan = session.get_is_in_retry() && enable_send_plan_event;
int last_query_retry_err = session.get_retry_info().get_last_query_retry_err();
if (OB_TRANSACTION_SET_VIOLATION == last_query_retry_err
|| OB_TRY_LOCK_ROW_CONFLICT == last_query_retry_err) {
if (OB_TRANSACTION_SET_VIOLATION == last_query_retry_err || OB_TRY_LOCK_ROW_CONFLICT == last_query_retry_err) {
enable_send_plan = false;
}
LOG_DEBUG("before after_get_plan", K(enable_send_plan), K(enable_send_plan_event),
"is_retry",session.get_is_in_retry());
LOG_DEBUG(
"before after_get_plan", K(enable_send_plan), K(enable_send_plan_event), "is_retry", session.get_is_in_retry());
// LOG_INFO("after get paln", K(pctx), K(phy_plan));
if (NULL != pctx) {
if (NULL != phy_plan) {
@ -3055,8 +3056,7 @@ int ObSql::after_get_plan(ObPlanCacheCtx& pc_ctx, ObSQLSessionInfo& session, ObP
} // end for
}
if (OB_SUCC(ret) && phy_plan->is_remote_plan() && !phy_plan->contains_temp_table() &&
GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_2250 &&
!enable_send_plan) {
GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_2250 && !enable_send_plan) {
ParamStore &param_store = pctx->get_param_store_for_update();
if (OB_NOT_NULL(ps_params)) {
int64_t initial_param_count = ps_params->count();

View File

@ -1615,8 +1615,8 @@ int ObPlanCache::construct_plan_cache_key(ObSQLSessionInfo& session, ObjNameSpac
uint64_t database_id = OB_INVALID_ID;
if (OB_FAIL(session.get_database_id(database_id))) {
LOG_WARN("get database id failed", K(ret));
} else if (FALSE_IT(pc_key.db_id_ = (database_id == OB_INVALID_ID) ?
OB_OUTLINE_DEFAULT_DATABASE_ID
} else if (FALSE_IT(pc_key.db_id_ = (database_id == OB_INVALID_ID) ? combine_id(session.get_effective_tenant_id(),
OB_OUTLINE_DEFAULT_DATABASE_ID)
: database_id)) {
// do nothing
} else {