[to #52917765] fix text anonymous blocks lock contending and support early when stop in query/session killed
This commit is contained in:
parent
ef922647e3
commit
f5393a44ae
@ -2142,9 +2142,14 @@ int ObPL::get_pl_function(ObExecContext &ctx,
|
||||
// not in cache, compile it and add to cache
|
||||
if (OB_SUCC(ret) && OB_ISNULL(routine)) {
|
||||
ParseNode root_node;
|
||||
ObBucketHashWLockGuard guard(codegen_lock_, stmt_id);
|
||||
// check cache again after get lock
|
||||
if (OB_FAIL(ObPLCacheMgr::get_pl_cache(ctx.get_my_session()->get_plan_cache(), cacheobj_guard, pc_ctx))) {
|
||||
uint64_t lock_idx = stmt_id != OB_INVALID_ID ? stmt_id : murmurhash(sql.ptr(), sql.length(), 0);
|
||||
ObBucketHashWLockGuard guard(codegen_lock_, lock_idx);
|
||||
// check session status after get lock
|
||||
if (OB_FAIL(check_session_alive(*ctx.get_my_session()))) {
|
||||
LOG_WARN("query or session is killed after get PL codegen lock", K(ret));
|
||||
|
||||
// check cache again after get lock
|
||||
} else if (OB_FAIL(ObPLCacheMgr::get_pl_cache(ctx.get_my_session()->get_plan_cache(), cacheobj_guard, pc_ctx))) {
|
||||
LOG_INFO("get pl function by sql failed, will ignore this error",
|
||||
K(ret), K(pc_ctx.key_), K(stmt_id), K(sql), K(params));
|
||||
ret = OB_ERR_UNEXPECTED != ret ? OB_SUCCESS : ret;
|
||||
@ -2251,8 +2256,12 @@ int ObPL::get_pl_function(ObExecContext &ctx,
|
||||
bool need_update_schema = false;
|
||||
{
|
||||
ObBucketHashWLockGuard guard(codegen_lock_, routine_id);
|
||||
// check again after get lock.
|
||||
if (OB_FAIL(ObPLCacheMgr::get_pl_cache(ctx.get_my_session()->get_plan_cache(), cacheobj_guard, pc_ctx))) {
|
||||
// check session status after get lock
|
||||
if (OB_FAIL(check_session_alive(*ctx.get_my_session()))){
|
||||
LOG_WARN("query or session is killed after get PL codegen lock", K(ret));
|
||||
|
||||
// check pl cache again after get lock.
|
||||
} else if (OB_FAIL(ObPLCacheMgr::get_pl_cache(ctx.get_my_session()->get_plan_cache(), cacheobj_guard, pc_ctx))) {
|
||||
LOG_INFO("get pl function from plan cache failed",
|
||||
K(ret), K(pc_ctx.key_), K(package_id), K(routine_id));
|
||||
ret = OB_ERR_UNEXPECTED != ret ? OB_SUCCESS : ret;
|
||||
@ -4376,5 +4385,17 @@ int ObPLINS::get_not_null(const ObPLDataType &pl_type,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObPL::check_session_alive(const ObBasicSessionInfo &session) {
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(session.is_query_killed())) {
|
||||
ret = OB_ERR_QUERY_INTERRUPTED;
|
||||
LOG_WARN("query is killed", K(ret));
|
||||
} else if (OB_UNLIKELY(session.is_zombie())) {
|
||||
ret = OB_ERR_SESSION_INTERRUPTED;
|
||||
LOG_WARN("session is killed", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace pl
|
||||
}
|
||||
|
@ -1205,6 +1205,8 @@ public:
|
||||
|
||||
ObBucketLock& get_jit_lock() { return jit_lock_; }
|
||||
|
||||
static int check_session_alive(const ObBasicSessionInfo &session);
|
||||
|
||||
private:
|
||||
common::ObMySQLProxy *sql_proxy_;
|
||||
ObPLPackageManager package_manager_;
|
||||
|
@ -231,8 +231,12 @@ int ObPLCompiler::compile(
|
||||
lib::is_oracle_mode()) {
|
||||
#endif
|
||||
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "PlCodeGen"));
|
||||
ObBucketHashWLockGuard compile_guard(GCTX.pl_engine_->get_jit_lock(), stmt_id);
|
||||
if (OB_FAIL(cg.init())) {
|
||||
uint64_t lock_idx = stmt_id != OB_INVALID_ID ? stmt_id : murmurhash(block->str_value_, block->str_len_, 0);
|
||||
ObBucketHashWLockGuard compile_guard(GCTX.pl_engine_->get_jit_lock(), lock_idx);
|
||||
// check session status after get lock
|
||||
if (OB_FAIL(ObPL::check_session_alive(session_info_))) {
|
||||
LOG_WARN("query or session is killed after get PL jit lock", K(ret));
|
||||
} else if (OB_FAIL(cg.init())) {
|
||||
LOG_WARN("failed to init code generator", K(ret));
|
||||
} else if (OB_FAIL(cg.generate(func))) {
|
||||
LOG_WARN("failed to code generate for stmt", K(ret));
|
||||
@ -467,7 +471,10 @@ int ObPLCompiler::compile(const uint64_t id, ObPLFunction &func)
|
||||
#endif
|
||||
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "PlCodeGen"));
|
||||
ObBucketHashWLockGuard compile_guard(GCTX.pl_engine_->get_jit_lock(), id);
|
||||
if (OB_FAIL(cg.init())) {
|
||||
// check session status after get lock
|
||||
if (OB_FAIL(ObPL::check_session_alive(session_info_))) {
|
||||
LOG_WARN("query or session is killed after get PL jit lock", K(ret));
|
||||
} else if (OB_FAIL(cg.init())) {
|
||||
LOG_WARN("failed to init code generator", K(ret));
|
||||
} else if (OB_FAIL(cg.generate(func))) {
|
||||
LOG_WARN("failed to code generate for stmt", K(ret));
|
||||
@ -776,6 +783,11 @@ int ObPLCompiler::compile_package(const ObPackageInfo &package_info,
|
||||
package_ast, package_info.is_for_trigger()));
|
||||
|
||||
ObBucketHashWLockGuard compile_guard(GCTX.pl_engine_->get_jit_lock(), package.get_id());
|
||||
// check session status after get lock
|
||||
if (OB_SUCC(ret) && OB_FAIL(ObPL::check_session_alive(session_info_))) {
|
||||
LOG_WARN("query or session is killed after get PL jit lock", K(ret));
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
#ifdef USE_MCJIT
|
||||
HEAP_VAR(ObPLCodeGenerator, cg ,allocator_, session_info_) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user