[CP] Split prepare stmt memory to tenants
This commit is contained in:
@ -23,11 +23,10 @@ template<int64_t MAX_RESERVE_SIZE = 0>
|
|||||||
class ObReserveArenaAllocator : public ObIAllocator
|
class ObReserveArenaAllocator : public ObIAllocator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObReserveArenaAllocator(const lib::ObLabel &label,
|
ObReserveArenaAllocator(const lib::ObMemAttr &attr,
|
||||||
const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE,
|
const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE)
|
||||||
int64_t tenant_id = OB_SERVER_TENANT_ID)
|
|
||||||
: pos_(0),
|
: pos_(0),
|
||||||
allocator_(label, page_size, tenant_id)
|
allocator_(attr, page_size)
|
||||||
{
|
{
|
||||||
OB_ASSERT(MAX_RESERVE_SIZE >= 0);
|
OB_ASSERT(MAX_RESERVE_SIZE >= 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -314,7 +314,7 @@ typedef common::ObSEArray<bool, 16> ParamCastArray;
|
|||||||
class ObPsSessionInfo
|
class ObPsSessionInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObPsSessionInfo(const int64_t num_of_params) :
|
ObPsSessionInfo(const int64_t tenant_id, const int64_t num_of_params) :
|
||||||
stmt_id_(common::OB_INVALID_STMT_ID),
|
stmt_id_(common::OB_INVALID_STMT_ID),
|
||||||
stmt_type_(stmt::T_NONE),
|
stmt_type_(stmt::T_NONE),
|
||||||
num_of_params_(num_of_params),
|
num_of_params_(num_of_params),
|
||||||
@ -323,6 +323,8 @@ public:
|
|||||||
inner_stmt_id_(0),
|
inner_stmt_id_(0),
|
||||||
num_of_returning_into_(common::OB_INVALID_STMT_ID) // num_of_returning_into_ init as -1
|
num_of_returning_into_(common::OB_INVALID_STMT_ID) // num_of_returning_into_ init as -1
|
||||||
{
|
{
|
||||||
|
param_types_.set_attr(ObMemAttr(tenant_id, "ParamTypes"));
|
||||||
|
param_type_infos_.set_attr(ObMemAttr(tenant_id, "ParamTypesInfo"));
|
||||||
param_types_.reserve(num_of_params_);
|
param_types_.reserve(num_of_params_);
|
||||||
}
|
}
|
||||||
//{ param_types_.set_label(common::ObModIds::OB_PS_SESSION_INFO_ARRAY); }
|
//{ param_types_.set_label(common::ObModIds::OB_PS_SESSION_INFO_ARRAY); }
|
||||||
|
|||||||
@ -81,15 +81,15 @@ ObBasicSessionInfo::ObBasicSessionInfo(const uint64_t tenant_id)
|
|||||||
sess_ref_seq_(0),
|
sess_ref_seq_(0),
|
||||||
block_allocator_(SMALL_BLOCK_SIZE, common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
block_allocator_(SMALL_BLOCK_SIZE, common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
||||||
//这里减32是为了适配ObMalloc对齐规则, 防止超8k的内存分配
|
//这里减32是为了适配ObMalloc对齐规则, 防止超8k的内存分配
|
||||||
ObMalloc(ObModIds::OB_SQL_SESSION_SBLOCK)),
|
ObMalloc(lib::ObMemAttr(orig_tenant_id_, ObModIds::OB_SQL_SESSION_SBLOCK))),
|
||||||
ps_session_info_allocator_(sizeof(ObPsSessionInfo), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
ps_session_info_allocator_(sizeof(ObPsSessionInfo), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
||||||
//这里减32是为了适配ObMalloc对齐规则, 防止超8k的内存分配
|
//这里减32是为了适配ObMalloc对齐规则, 防止超8k的内存分配
|
||||||
ObMalloc("PsSessionInfo")),
|
ObMalloc(lib::ObMemAttr(orig_tenant_id_, "PsSessionInfo"))),
|
||||||
cursor_info_allocator_(sizeof(pl::ObDbmsCursorInfo), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
cursor_info_allocator_(sizeof(pl::ObDbmsCursorInfo), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
||||||
ObMalloc("SessCursorInfo")),
|
ObMalloc(lib::ObMemAttr(orig_tenant_id_, "SessCursorInfo"))),
|
||||||
package_info_allocator_(sizeof(pl::ObPLPackageState), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
package_info_allocator_(sizeof(pl::ObPLPackageState), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
||||||
ObMalloc("SessPackageInfo")),
|
ObMalloc(lib::ObMemAttr(orig_tenant_id_, "SessPackageInfo"))),
|
||||||
name_pool_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
|
name_pool_(lib::ObMemAttr(orig_tenant_id_, ObModIds::OB_SQL_SESSION), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||||
trans_flags_(),
|
trans_flags_(),
|
||||||
sql_scope_flags_(),
|
sql_scope_flags_(),
|
||||||
need_reset_package_(false),
|
need_reset_package_(false),
|
||||||
@ -119,8 +119,8 @@ ObBasicSessionInfo::ObBasicSessionInfo(const uint64_t tenant_id)
|
|||||||
client_mode_(OB_MIN_CLIENT_MODE),
|
client_mode_(OB_MIN_CLIENT_MODE),
|
||||||
changed_sys_vars_(),
|
changed_sys_vars_(),
|
||||||
changed_user_vars_(),
|
changed_user_vars_(),
|
||||||
changed_var_pool_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
|
changed_var_pool_(ObMemAttr(orig_tenant_id_, ObModIds::OB_SQL_SESSION), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||||
extra_info_allocator_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
|
extra_info_allocator_(ObMemAttr(orig_tenant_id_, ObModIds::OB_SQL_SESSION), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||||
is_database_changed_(false),
|
is_database_changed_(false),
|
||||||
feedback_manager_(),
|
feedback_manager_(),
|
||||||
trans_spec_status_(TRANS_SPEC_NOT_SET),
|
trans_spec_status_(TRANS_SPEC_NOT_SET),
|
||||||
|
|||||||
@ -1154,7 +1154,7 @@ int ObSQLSessionInfo::prepare_ps_stmt(const ObPsStmtId inner_stmt_id,
|
|||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("stmt info is null", K(ret), K(stmt_info));
|
LOG_WARN("stmt info is null", K(ret), K(stmt_info));
|
||||||
} else {
|
} else {
|
||||||
session_info = new (buf) ObPsSessionInfo(stmt_info->get_num_of_param());
|
session_info = new (buf) ObPsSessionInfo(orig_tenant_id_, stmt_info->get_num_of_param());
|
||||||
session_info->set_stmt_id(client_stmt_id);
|
session_info->set_stmt_id(client_stmt_id);
|
||||||
session_info->set_stmt_type(stmt_info->get_stmt_type());
|
session_info->set_stmt_type(stmt_info->get_stmt_type());
|
||||||
session_info->set_ps_stmt_checksum(stmt_info->get_ps_stmt_checksum());
|
session_info->set_ps_stmt_checksum(stmt_info->get_ps_stmt_checksum());
|
||||||
|
|||||||
@ -445,8 +445,8 @@ struct ObInnerContextMap {
|
|||||||
} else {
|
} else {
|
||||||
new (context_map_) ObInnerContextHashMap ();
|
new (context_map_) ObInnerContextHashMap ();
|
||||||
if (OB_FAIL(context_map_->create(hash::cal_next_prime(32),
|
if (OB_FAIL(context_map_->create(hash::cal_next_prime(32),
|
||||||
ObModIds::OB_HASH_BUCKET,
|
ObModIds::OB_HASH_BUCKET,
|
||||||
ObModIds::OB_HASH_NODE))) {
|
ObModIds::OB_HASH_NODE))) {
|
||||||
SQL_ENG_LOG(WARN, "failed to init hash map", K(ret));
|
SQL_ENG_LOG(WARN, "failed to init hash map", K(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1247,7 +1247,8 @@ private:
|
|||||||
if (OB_UNLIKELY(!ps_session_info_map_.created())) {
|
if (OB_UNLIKELY(!ps_session_info_map_.created())) {
|
||||||
ret = ps_session_info_map_.create(common::hash::cal_next_prime(PS_BUCKET_NUM),
|
ret = ps_session_info_map_.create(common::hash::cal_next_prime(PS_BUCKET_NUM),
|
||||||
common::ObModIds::OB_HASH_BUCKET_PS_SESSION_INFO,
|
common::ObModIds::OB_HASH_BUCKET_PS_SESSION_INFO,
|
||||||
common::ObModIds::OB_HASH_NODE_PS_SESSION_INFO);
|
common::ObModIds::OB_HASH_NODE_PS_SESSION_INFO,
|
||||||
|
orig_tenant_id_);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1262,7 +1263,8 @@ private:
|
|||||||
if (OB_UNLIKELY(!ps_name_id_map_.created())) {
|
if (OB_UNLIKELY(!ps_name_id_map_.created())) {
|
||||||
ret = ps_name_id_map_.create(common::hash::cal_next_prime(PS_BUCKET_NUM),
|
ret = ps_name_id_map_.create(common::hash::cal_next_prime(PS_BUCKET_NUM),
|
||||||
common::ObModIds::OB_HASH_BUCKET_PS_SESSION_INFO,
|
common::ObModIds::OB_HASH_BUCKET_PS_SESSION_INFO,
|
||||||
common::ObModIds::OB_HASH_NODE_PS_SESSION_INFO);
|
common::ObModIds::OB_HASH_NODE_PS_SESSION_INFO,
|
||||||
|
orig_tenant_id_);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,8 +71,8 @@ int ObRowsInfo::ExistHelper::init(const ObRelativeTable &table,
|
|||||||
|
|
||||||
|
|
||||||
ObRowsInfo::ObRowsInfo()
|
ObRowsInfo::ObRowsInfo()
|
||||||
: scan_mem_allocator_(common::ObModIds::OB_STORE_ROW_EXISTER, OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID()),
|
: scan_mem_allocator_(ObMemAttr(MTL_ID(), common::ObModIds::OB_STORE_ROW_EXISTER), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||||
key_allocator_(common::ObModIds::OB_STORE_ROW_EXISTER, OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID()),
|
key_allocator_(ObMemAttr(MTL_ID(), common::ObModIds::OB_STORE_ROW_EXISTER), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||||
rowkeys_(),
|
rowkeys_(),
|
||||||
rows_(nullptr),
|
rows_(nullptr),
|
||||||
exist_helper_(),
|
exist_helper_(),
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public:
|
|||||||
ObReserveArenaAllocator<1024> test_allocator_;
|
ObReserveArenaAllocator<1024> test_allocator_;
|
||||||
};
|
};
|
||||||
TestReserveArenaAllocator::TestReserveArenaAllocator():
|
TestReserveArenaAllocator::TestReserveArenaAllocator():
|
||||||
test_allocator_(ObModIds::OB_STORE_ROW_EXISTER, OB_MALLOC_NORMAL_BLOCK_SIZE, 500)
|
test_allocator_(ObMemAttr(500, ObModIds::OB_STORE_ROW_EXISTER), OB_MALLOC_NORMAL_BLOCK_SIZE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,4 +151,4 @@ int main(int argc, char **argv)
|
|||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user