[CP] [to #50146855] add concurrency control for PL compilation
This commit is contained in:
@ -190,6 +190,7 @@ int ObPL::init(common::ObMySQLProxy &sql_proxy)
|
||||
|
||||
sql_proxy_ = &sql_proxy;
|
||||
OZ (codegen_lock_.init(1024));
|
||||
OZ (jit_lock_.init(32));
|
||||
OZ (interface_service_.init());
|
||||
OX (serialize_composite_callback = ObUserDefinedType::serialize_obj);
|
||||
OX (deserialize_composite_callback = ObUserDefinedType::deserialize_obj);
|
||||
@ -1749,7 +1750,9 @@ int ObPL::execute(ObExecContext &ctx, ParamStore ¶ms, const ObStmtNodeTree *
|
||||
K(ret), K(sizeof(ObPLFunction)));
|
||||
}
|
||||
OX (routine = new(routine)ObPLFunction(mem_context));
|
||||
OZ (compiler.compile(block, *routine, ¶ms, false));
|
||||
|
||||
// stmt_id is OB_INVALID_ID for anonymous block from text protocol
|
||||
OZ (compiler.compile(block, OB_INVALID_ID, *routine, ¶ms, false));
|
||||
OX (routine->set_debug_priv());
|
||||
}
|
||||
}
|
||||
@ -2148,7 +2151,7 @@ int ObPL::get_pl_function(ObExecContext &ctx,
|
||||
}
|
||||
OX (routine = static_cast<ObPLFunction*>(cacheobj_guard.get_cache_obj()));
|
||||
if (OB_SUCC(ret) && OB_ISNULL(routine)) {
|
||||
OZ (generate_pl_function(ctx, sql, params, root_node, cacheobj_guard));
|
||||
OZ (generate_pl_function(ctx, sql, params, root_node, cacheobj_guard, stmt_id));
|
||||
OX (routine = static_cast<ObPLFunction*>(cacheobj_guard.get_cache_obj()));
|
||||
CK (OB_NOT_NULL(routine));
|
||||
if (OB_SUCC(ret) && routine->get_can_cached()) {
|
||||
@ -2333,6 +2336,7 @@ int ObPL::generate_pl_function(ObExecContext &ctx,
|
||||
ParamStore ¶ms,
|
||||
ParseNode &parse_node,
|
||||
ObCacheObjGuard& cacheobj_guard,
|
||||
const uint64_t stmt_id,
|
||||
bool is_anonymous_text)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2408,7 +2412,7 @@ int ObPL::generate_pl_function(ObExecContext &ctx,
|
||||
*(ctx.get_sql_proxy()));
|
||||
|
||||
OZ (compiler.compile(
|
||||
block_node, *routine, ¶ms, ctx.get_sql_ctx()->is_prepare_protocol_));
|
||||
block_node, stmt_id, *routine, ¶ms, ctx.get_sql_ctx()->is_prepare_protocol_));
|
||||
OZ (routine->set_params_info(params));
|
||||
}
|
||||
|
||||
|
||||
@ -1147,6 +1147,7 @@ private:
|
||||
ParamStore ¶ms,
|
||||
ParseNode &node,
|
||||
ObCacheObjGuard& cacheobj_guard,
|
||||
const uint64_t stmt_id,
|
||||
bool is_anonymous_text = false);
|
||||
|
||||
// for normal routine
|
||||
@ -1202,11 +1203,14 @@ public:
|
||||
|
||||
static int check_trigger_arg(const ParamStore ¶ms, const ObPLFunction &func);
|
||||
|
||||
ObBucketLock& get_jit_lock() { return jit_lock_; }
|
||||
|
||||
private:
|
||||
common::ObMySQLProxy *sql_proxy_;
|
||||
ObPLPackageManager package_manager_;
|
||||
ObPLInterfaceService interface_service_;
|
||||
common::ObBucketLock codegen_lock_;
|
||||
common::ObBucketLock jit_lock_;
|
||||
};
|
||||
|
||||
class LinkPLStackGuard
|
||||
|
||||
@ -168,6 +168,7 @@ int ObPLCompiler::init_anonymous_ast(
|
||||
//for anonymous
|
||||
int ObPLCompiler::compile(
|
||||
const ObStmtNodeTree *block,
|
||||
const uint64_t stmt_id,
|
||||
ObPLFunction &func,
|
||||
ParamStore *params/*=NULL*/,
|
||||
bool is_prepare_protocol/*=false*/)
|
||||
@ -230,6 +231,7 @@ 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())) {
|
||||
LOG_WARN("failed to init code generator", K(ret));
|
||||
} else if (OB_FAIL(cg.generate(func))) {
|
||||
@ -464,6 +466,7 @@ int ObPLCompiler::compile(const uint64_t id, ObPLFunction &func)
|
||||
lib::is_oracle_mode()) {
|
||||
#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())) {
|
||||
LOG_WARN("failed to init code generator", K(ret));
|
||||
} else if (OB_FAIL(cg.generate(func))) {
|
||||
@ -772,6 +775,7 @@ int ObPLCompiler::compile_package(const ObPackageInfo &package_info,
|
||||
OZ (analyze_package(source, parent_ns,
|
||||
package_ast, package_info.is_for_trigger()));
|
||||
|
||||
ObBucketHashWLockGuard compile_guard(GCTX.pl_engine_->get_jit_lock(), package.get_id());
|
||||
if (OB_SUCC(ret)) {
|
||||
#ifdef USE_MCJIT
|
||||
HEAP_VAR(ObPLCodeGenerator, cg ,allocator_, session_info_) {
|
||||
|
||||
@ -50,6 +50,7 @@ public:
|
||||
virtual ~ObPLCompiler() {}
|
||||
|
||||
int compile(const ObStmtNodeTree *block,
|
||||
const uint64_t stmt_id,
|
||||
ObPLFunction &func,
|
||||
ParamStore *params,
|
||||
bool is_prepare_protocol); //匿名块接口
|
||||
|
||||
Reference in New Issue
Block a user