[CP] xml tenant memory leak

This commit is contained in:
obdev 2023-09-20 17:01:21 +00:00 committed by ob-robot
parent 8b22206e30
commit d2afa610a2
13 changed files with 21 additions and 19 deletions

View File

@ -1084,7 +1084,7 @@ int ObMySQLUtil::sql_utd_cell_str(uint64_t tenant_id, char *buf, const int64_t l
{
INIT_SUCC(ret);
#ifdef OB_BUILD_ORACLE_XML
lib::ObMemAttr mem_attr(tenant_id, "XMLCodeGen");
lib::ObMemAttr mem_attr(tenant_id, "XMLModule");
lib::ObMallocHookAttrGuard malloc_guard(mem_attr);
ObArenaAllocator allocator(mem_attr);
ObMulModeNodeType node_type = M_MAX_TYPE;

View File

@ -6699,7 +6699,7 @@ int ObAggregateProcessor::get_ora_xmlagg_result(const ObAggrInfo &aggr_info,
ObMulModeMemCtx* xml_mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(eval_ctx_.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(eval_ctx_.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(eval_ctx_.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;

View File

@ -103,7 +103,7 @@ int ObExprExtractValue::eval_extract_value(const ObExpr &expr, ObEvalCtx &ctx, O
ObString xml_res;
ObCollationType cs_type = CS_TYPE_INVALID;
ObMulModeMemCtx* xml_mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;

View File

@ -101,7 +101,7 @@ int ObExprExtractXml::eval_extract_xml(const ObExpr &expr, ObEvalCtx &ctx, ObDat
// eval arg
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;

View File

@ -112,7 +112,7 @@ int ObExprPrivXmlBinary::eval_priv_xml_binary(const ObExpr &expr, ObEvalCtx &ctx
? expr.args_[1]->obj_meta_.get_type()
: ObLongTextType;
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "XMLModule"));
if (OB_FAIL(ObXmlUtil::create_mulmode_tree_context(&tmp_allocator, mem_ctx))) {
LOG_WARN("fail to create tree memory context", K(ret));
} else if (OB_FAIL(ObTextStringHelper::read_real_string_data(&tmp_allocator,

View File

@ -99,7 +99,7 @@ int ObExprSysMakeXML::eval_sys_makexml(const ObExpr &expr, ObEvalCtx &ctx, ObDat
common::ObArenaAllocator &allocator = tmp_alloc_g.get_allocator();
ObString full_xml_data;
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "XMLModule"));
if (OB_FAIL(ret)) {
} else if (OB_FAIL(ObXmlUtil::create_mulmode_tree_context(&allocator, mem_ctx))) {

View File

@ -119,7 +119,7 @@ int ObExprUpdateXml::eval_update_xml(const ObExpr &expr, ObEvalCtx &ctx, ObDatum
ObMulModeMemCtx* xml_mem_ctx = nullptr;
bool input_is_doc = false;
ObMulModeNodeType node_type = M_MAX_TYPE;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;

View File

@ -110,7 +110,8 @@ int ObExprXmlElement::eval_xml_element(const ObExpr &expr, ObEvalCtx &ctx, ObDat
ObString name_tag;
int need_escape = 0;
int is_name = 0;
ObVector<ObObj> value_vec;
ObVector<ObObj, ElementObjCacheStatArena> value_vec;
const ObIJsonBase *attr_json = NULL;
ObString binary_str;
ObString blob_locator;
@ -118,7 +119,7 @@ int ObExprXmlElement::eval_xml_element(const ObExpr &expr, ObEvalCtx &ctx, ObDat
ObXmlElement *element = NULL;
ObXmlDocument *res_doc = NULL;
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;
@ -291,7 +292,7 @@ int ObExprXmlElement::eval_xml_element(const ObExpr &expr, ObEvalCtx &ctx, ObDat
return ret;
}
int ObExprXmlElement::construct_value_array(ObIAllocator &allocator, const ObString &value, ObVector<ObObj> &res_value)
int ObExprXmlElement::construct_value_array(ObIAllocator &allocator, const ObString &value, ObVector<ObObj, ElementObjCacheStatArena> &res_value)
{
INIT_SUCC(ret);
if (value.empty()) {
@ -365,7 +366,7 @@ int ObExprXmlElement::construct_attribute(ObMulModeMemCtx* mem_ctx, const ObIJso
}
int ObExprXmlElement::construct_element_children(ObMulModeMemCtx* mem_ctx,
ObVector<ObObj> &value_vec,
ObVector<ObObj, ElementObjCacheStatArena> &value_vec,
ObXmlElement *&element,
ObXmlElement *valid_ele)
{
@ -422,7 +423,7 @@ int ObExprXmlElement::construct_element_children(ObMulModeMemCtx* mem_ctx,
int ObExprXmlElement::construct_element(ObMulModeMemCtx* mem_ctx,
const ObString &name,
ObVector<ObObj> &value_vec,
ObVector<ObObj, ElementObjCacheStatArena> &value_vec,
const ObIJsonBase *attr,
ObXmlElement *&element,
bool &validity)

View File

@ -29,6 +29,7 @@ namespace oceanbase
{
namespace sql
{
typedef PageArena<ObObj, ModulePageAllocator> ElementObjCacheStatArena;
class
ObExprXmlElement : public ObFuncExprOperator
{
@ -55,7 +56,7 @@ private:
ObString &str);
static int construct_element(ObMulModeMemCtx* mem_ctx,
const ObString &name,
ObVector<ObObj> &value_vec,
ObVector<ObObj, ElementObjCacheStatArena> &value_vec,
const ObIJsonBase *attr,
ObXmlElement *&element,
bool &validity);
@ -63,12 +64,12 @@ private:
const ObIJsonBase *attr,
ObXmlElement *&element);
static int construct_element_children(ObMulModeMemCtx* mem_ctx,
ObVector<ObObj> &value_vec,
ObVector<ObObj, ElementObjCacheStatArena> &value_vec,
ObXmlElement *&element,
ObXmlElement *valid_ele);
static int construct_value_array(ObIAllocator &allocator,
const ObString &value,
ObVector<ObObj> &res_value);
ObVector<ObObj, ElementObjCacheStatArena> &res_value);
#endif
DISALLOW_COPY_AND_ASSIGN(ObExprXmlElement);
};

View File

@ -135,7 +135,7 @@ int ObExprXmlSerialize::eval_xml_serialize(const ObExpr &expr, ObEvalCtx &ctx, O
ObDatum *xml_datum = NULL;
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;

View File

@ -160,7 +160,7 @@ int ObExprXmlcast::eval_xmlcast(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res
ObCollationType cs_type = CS_TYPE_INVALID;
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;

View File

@ -101,7 +101,7 @@ int ObExprXmlparse::eval_xmlparse(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &r
ObEvalCtx::TempAllocGuard tmp_alloc_g(ctx);
common::ObArenaAllocator &tmp_allocator = tmp_alloc_g.get_allocator();
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(ObXMLExprHelper::get_tenant_id(ctx.exec_ctx_.get_my_session()), "XMLModule"));
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;

View File

@ -4608,7 +4608,7 @@ int ObAlterTableResolver::add_udt_hidden_column(ObAlterTableStmt *alter_table_st
// convert to xml binary
ObXmlDocument *xml_doc = NULL;
ObMulModeMemCtx* mem_ctx = nullptr;
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "XMLCodeGen"));
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(MTL_ID(), "XMLModule"));
if (OB_FAIL(ObXmlUtil::create_mulmode_tree_context(allocator_, mem_ctx))) {
LOG_WARN("fail to create tree memory context", K(ret));
} else if (OB_FAIL(ObXmlParserUtils::parse_document_text(mem_ctx,